@@ -20,9 +20,6 @@ public sealed class ASFAchievementManager : IBotSteamClient, IBotCommand {
2020 public void OnLoaded ( ) => ASF . ArchiLogger . LogGenericInfo ( "ASF Achievement Manager Plugin by Ryzhehvost, powered by ginger cats" ) ;
2121
2222 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- }
2623
2724 switch ( args . Length ) {
2825 case 0 :
@@ -38,17 +35,17 @@ public async Task<string> OnBotCommand([NotNull] Bot bot, ulong steamID, [NotNul
3835 default :
3936 switch ( args [ 0 ] . ToUpperInvariant ( ) ) {
4037 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 ) ;
4239 case "ALIST" :
43- return await ResponseAchievementList ( bot , args [ 1 ] ) . ConfigureAwait ( false ) ;
40+ return await ResponseAchievementList ( steamID , bot , args [ 1 ] ) . ConfigureAwait ( false ) ;
4441 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 ) ;
4643 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 ) ;
4845 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 ) ;
5047 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 ) ;
5249 default :
5350 return null ;
5451 }
@@ -65,7 +62,12 @@ public IReadOnlyCollection<ClientMsgHandler> OnBotSteamHandlersInit([NotNull] Bo
6562
6663 //Responses
6764
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+
6971 string [ ] gameIDs = appids . Split ( new [ ] { ',' } , StringSplitOptions . RemoveEmptyEntries ) ;
7072
7173 if ( gameIDs . Length == 0 ) {
@@ -97,23 +99,27 @@ private static async Task<string> ResponseAchievementList(Bot bot, string appids
9799
98100 }
99101
100- private static async Task < string > ResponseAchievementList ( string botNames , string appids ) {
102+ private static async Task < string > ResponseAchievementList ( ulong steamID , string botNames , string appids ) {
101103
102104 HashSet < Bot > bots = Bot . GetBots ( botNames ) ;
103105
104106 if ( ( bots == null ) || ( bots . Count == 0 ) ) {
105107 return Commands . FormatStaticResponse ( string . Format ( Strings . BotNotFound , botNames ) ) ;
106108 }
107109
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 ) ;
109111
110112 List < string > responses = new List < string > ( results . Where ( result => ! string . IsNullOrEmpty ( result ) ) ) ;
111113
112114 return responses . Count > 0 ? string . Join ( Environment . NewLine , responses ) : null ;
113115 }
114116
115117
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+
117123 if ( string . IsNullOrEmpty ( AchievementNumbers ) ) {
118124 return bot . Commands . FormatBotResponse ( string . Format ( Strings . ErrorObjectIsNull , nameof ( AchievementNumbers ) ) ) ;
119125 }
@@ -144,15 +150,15 @@ private static async Task<string> ResponseAchievementSet(Bot bot, string appid,
144150 return bot . Commands . FormatBotResponse ( await Task . Run < string > ( ( ) => AchievementHandler . SetAchievements ( bot , appId , achievements , set ) ) . ConfigureAwait ( false ) ) ;
145151 }
146152
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 ) {
148154
149155 HashSet < Bot > bots = Bot . GetBots ( botNames ) ;
150156
151157 if ( ( bots == null ) || ( bots . Count == 0 ) ) {
152158 return Commands . FormatStaticResponse ( string . Format ( Strings . BotNotFound , botNames ) ) ;
153159 }
154160
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 ) ;
156162
157163 List < string > responses = new List < string > ( results . Where ( result => ! string . IsNullOrEmpty ( result ) ) ) ;
158164
0 commit comments