@@ -20,9 +20,6 @@ public sealed class ASFAchievementManager : IBotSteamClient, IBotCommand {
20
20
public void OnLoaded ( ) => ASF . ArchiLogger . LogGenericInfo ( "ASF Achievement Manager Plugin by Ryzhehvost, powered by ginger cats" ) ;
21
21
22
22
public async Task < string > OnBotCommand ( [ NotNull ] Bot bot , ulong steamID , [ NotNull ] string message , string [ ] args ) {
23
- if ( ! bot . HasPermission ( steamID , BotConfig . EPermission . Master ) ) {
24
- return null ;
25
- }
26
23
27
24
switch ( args . Length ) {
28
25
case 0 :
@@ -38,17 +35,17 @@ public async Task<string> OnBotCommand([NotNull] Bot bot, ulong steamID, [NotNul
38
35
default :
39
36
switch ( args [ 0 ] . ToUpperInvariant ( ) ) {
40
37
case "ALIST" when args . Length > 2 :
41
- return await ResponseAchievementList ( args [ 1 ] , Utilities . GetArgsAsText ( args , 2 , "," ) ) . ConfigureAwait ( false ) ;
38
+ return await ResponseAchievementList ( steamID , args [ 1 ] , Utilities . GetArgsAsText ( args , 2 , "," ) ) . ConfigureAwait ( false ) ;
42
39
case "ALIST" :
43
- return await ResponseAchievementList ( bot , args [ 1 ] ) . ConfigureAwait ( false ) ;
40
+ return await ResponseAchievementList ( steamID , bot , args [ 1 ] ) . ConfigureAwait ( false ) ;
44
41
case "ASET" when args . Length > 3 :
45
- return await ResponseAchievementSet ( args [ 1 ] , args [ 2 ] , Utilities . GetArgsAsText ( args , 3 , "," ) , true ) . ConfigureAwait ( false ) ;
42
+ return await ResponseAchievementSet ( steamID , args [ 1 ] , args [ 2 ] , Utilities . GetArgsAsText ( args , 3 , "," ) , true ) . ConfigureAwait ( false ) ;
46
43
case "ASET" when args . Length > 2 :
47
- return await ResponseAchievementSet ( bot , args [ 1 ] , Utilities . GetArgsAsText ( args , 2 , "," ) , true ) . ConfigureAwait ( false ) ;
44
+ return await ResponseAchievementSet ( steamID , bot , args [ 1 ] , Utilities . GetArgsAsText ( args , 2 , "," ) , true ) . ConfigureAwait ( false ) ;
48
45
case "ARESET" when args . Length > 3 :
49
- return await ResponseAchievementSet ( args [ 1 ] , args [ 2 ] , Utilities . GetArgsAsText ( args , 3 , "," ) , false ) . ConfigureAwait ( false ) ;
46
+ return await ResponseAchievementSet ( steamID , args [ 1 ] , args [ 2 ] , Utilities . GetArgsAsText ( args , 3 , "," ) , false ) . ConfigureAwait ( false ) ;
50
47
case "ARESET" when args . Length > 2 :
51
- return await ResponseAchievementSet ( bot , args [ 1 ] , Utilities . GetArgsAsText ( args , 2 , "," ) , false ) . ConfigureAwait ( false ) ;
48
+ return await ResponseAchievementSet ( steamID , bot , args [ 1 ] , Utilities . GetArgsAsText ( args , 2 , "," ) , false ) . ConfigureAwait ( false ) ;
52
49
default :
53
50
return null ;
54
51
}
@@ -65,7 +62,12 @@ public IReadOnlyCollection<ClientMsgHandler> OnBotSteamHandlersInit([NotNull] Bo
65
62
66
63
//Responses
67
64
68
- private static async Task < string > ResponseAchievementList ( Bot bot , string appids ) {
65
+ private static async Task < string > ResponseAchievementList ( ulong steamID , Bot bot , string appids ) {
66
+
67
+ if ( ! bot . HasPermission ( steamID , BotConfig . EPermission . Master ) ) {
68
+ return null ;
69
+ }
70
+
69
71
string [ ] gameIDs = appids . Split ( new [ ] { ',' } , StringSplitOptions . RemoveEmptyEntries ) ;
70
72
71
73
if ( gameIDs . Length == 0 ) {
@@ -97,23 +99,27 @@ private static async Task<string> ResponseAchievementList(Bot bot, string appids
97
99
98
100
}
99
101
100
- private static async Task < string > ResponseAchievementList ( string botNames , string appids ) {
102
+ private static async Task < string > ResponseAchievementList ( ulong steamID , string botNames , string appids ) {
101
103
102
104
HashSet < Bot > bots = Bot . GetBots ( botNames ) ;
103
105
104
106
if ( ( bots == null ) || ( bots . Count == 0 ) ) {
105
107
return Commands . FormatStaticResponse ( string . Format ( Strings . BotNotFound , botNames ) ) ;
106
108
}
107
109
108
- IList < string > results = await Utilities . InParallel ( bots . Select ( bot => ResponseAchievementList ( bot , appids ) ) ) . ConfigureAwait ( false ) ;
110
+ IList < string > results = await Utilities . InParallel ( bots . Select ( bot => ResponseAchievementList ( steamID , bot , appids ) ) ) . ConfigureAwait ( false ) ;
109
111
110
112
List < string > responses = new List < string > ( results . Where ( result => ! string . IsNullOrEmpty ( result ) ) ) ;
111
113
112
114
return responses . Count > 0 ? string . Join ( Environment . NewLine , responses ) : null ;
113
115
}
114
116
115
117
116
- private static async Task < string > ResponseAchievementSet ( Bot bot , string appid , string AchievementNumbers , bool set = true ) {
118
+ private static async Task < string > ResponseAchievementSet ( ulong steamID , Bot bot , string appid , string AchievementNumbers , bool set = true ) {
119
+ if ( ! bot . HasPermission ( steamID , BotConfig . EPermission . Master ) ) {
120
+ return null ;
121
+ }
122
+
117
123
if ( string . IsNullOrEmpty ( AchievementNumbers ) ) {
118
124
return bot . Commands . FormatBotResponse ( string . Format ( Strings . ErrorObjectIsNull , nameof ( AchievementNumbers ) ) ) ;
119
125
}
@@ -144,15 +150,15 @@ private static async Task<string> ResponseAchievementSet(Bot bot, string appid,
144
150
return bot . Commands . FormatBotResponse ( await Task . Run < string > ( ( ) => AchievementHandler . SetAchievements ( bot , appId , achievements , set ) ) . ConfigureAwait ( false ) ) ;
145
151
}
146
152
147
- private static async Task < string > ResponseAchievementSet ( string botNames , string appid , string AchievementNumbers , bool set = true ) {
153
+ private static async Task < string > ResponseAchievementSet ( ulong steamID , string botNames , string appid , string AchievementNumbers , bool set = true ) {
148
154
149
155
HashSet < Bot > bots = Bot . GetBots ( botNames ) ;
150
156
151
157
if ( ( bots == null ) || ( bots . Count == 0 ) ) {
152
158
return Commands . FormatStaticResponse ( string . Format ( Strings . BotNotFound , botNames ) ) ;
153
159
}
154
160
155
- IList < string > results = await Utilities . InParallel ( bots . Select ( bot => ResponseAchievementSet ( bot , appid , AchievementNumbers , set ) ) ) . ConfigureAwait ( false ) ;
161
+ IList < string > results = await Utilities . InParallel ( bots . Select ( bot => ResponseAchievementSet ( steamID , bot , appid , AchievementNumbers , set ) ) ) . ConfigureAwait ( false ) ;
156
162
157
163
List < string > responses = new List < string > ( results . Where ( result => ! string . IsNullOrEmpty ( result ) ) ) ;
158
164
0 commit comments