@@ -47,40 +47,32 @@ internal void AddPackage(Package package, HashSet<uint>? appIDsToRemove = null)
47
47
// I only really like to do this because the error messages for packages are more descriptive and useful.
48
48
BotCache . RemoveAppPackages ( appIDsToRemove ) ;
49
49
}
50
-
51
- UpdateTimer ( DateTime . Now ) ;
52
50
}
53
51
54
52
internal void AddPackages ( IEnumerable < Package > packages ) {
55
53
if ( ! BotCache . AddPackages ( packages ) ) {
56
54
return ;
57
55
}
58
-
59
- UpdateTimer ( DateTime . Now ) ;
60
56
}
61
57
62
58
private async Task ProcessQueue ( ) {
63
- DateTime ? lastActivation = BotCache . GetLastActivation ( ) ;
64
- if ( lastActivation != null && lastActivation . Value . AddSeconds ( DelayBetweenActivationsSeconds ) > DateTime . Now ) {
65
- UpdateTimer ( lastActivation . Value . AddSeconds ( DelayBetweenActivationsSeconds ) ) ;
66
-
67
- return ;
68
- }
69
-
70
59
if ( ! Bot . IsConnectedAndLoggedOn ) {
71
60
UpdateTimer ( DateTime . Now . AddMinutes ( 1 ) ) ;
72
61
73
62
return ;
74
63
}
75
64
76
- if ( BotCache . Packages . Count == 0 ) {
65
+ Package ? package = BotCache . GetNextPackage ( ) ;
66
+ if ( package == null ) {
67
+ // No packages to activate
77
68
UpdateTimer ( DateTime . Now . AddMinutes ( 1 ) ) ;
78
69
79
70
return ;
80
71
}
81
72
82
73
if ( BotCache . NumActivationsPastHour ( ) >= ActivationsPerHour ) {
83
- DateTime resumeTime = lastActivation ! . Value . AddHours ( 1 ) . AddMinutes ( 1 ) ;
74
+ // Rate limit reached
75
+ DateTime resumeTime = BotCache . GetLastActivation ( ) ! . Value . AddHours ( 1 ) . AddMinutes ( 1 ) ;
84
76
Bot . ArchiLogger . LogGenericInfo ( String . Format ( Strings . ActivationPaused , String . Format ( "{0:T}" , resumeTime ) ) ) ;
85
77
UpdateTimer ( resumeTime ) ;
86
78
@@ -94,14 +86,6 @@ private async Task ProcessQueue() {
94
86
return ;
95
87
}
96
88
97
- Package ? package = BotCache . GetNextPackage ( ) ;
98
- if ( package == null ) {
99
- // There are packages to redeem, but they aren't active yet
100
- UpdateTimer ( DateTime . Now . AddMinutes ( 1 ) ) ;
101
-
102
- return ;
103
- }
104
-
105
89
EResult result = await ClaimPackage ( package ) . ConfigureAwait ( false ) ;
106
90
107
91
if ( result == EResult . RateLimitExceeded ) {
@@ -115,7 +99,7 @@ private async Task ProcessQueue() {
115
99
}
116
100
117
101
// Note: Not everything counts against the activation limit, ex: All playtests?, Some sub errors (dunno which), Maybe some app errors
118
- // Might be worth revisiting later, but for now I feel comfortable just assuming everything counts
102
+ // Might be worth revisiting later, but for now I feel comfortable just assuming everything that doesnt get a rate limit response counts
119
103
BotCache . AddActivation ( DateTime . Now ) ;
120
104
121
105
if ( result == EResult . OK || result == EResult . Invalid ) {
0 commit comments