From eb09fcb3bd91a08ff96e93a7433536447bc803e6 Mon Sep 17 00:00:00 2001 From: Madpeterz <57852827+Madpeterz@users.noreply.github.com> Date: Tue, 23 Mar 2021 00:03:54 +0000 Subject: [PATCH] Update Group.cs adds power checks and messages for group commands --- Core/Commands/Group.cs | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/Core/Commands/Group.cs b/Core/Commands/Group.cs index 6ec3d1a..21089b5 100644 --- a/Core/Commands/Group.cs +++ b/Core/Commands/Group.cs @@ -118,6 +118,11 @@ namespace BetterSecondBot.HttpService { return Failure("Unknown group", "GroupBan", new string[] { group, avatar, state }); } + Group G = bot.MyGroups[groupuuid]; + if (G.Powers.HasFlag(GroupPowers.GroupBanAccess) == false) + { + return Failure("Missing group GroupBanAccess power", "GroupBan", new string[] { group, avatar, state }); + } if (bool.TryParse(state, out bool banstate) == false) { return Failure("Invaild ban state", "GroupBan", new string[] { group, avatar, state }); @@ -164,6 +169,11 @@ namespace BetterSecondBot.HttpService { return Failure("Unknown group", "GroupEject", new string[] { group, avatar }); } + Group G = bot.MyGroups[groupuuid]; + if (G.Powers.HasFlag(GroupPowers.Eject) == false) + { + return Failure("Missing group Eject power", "GroupEject", new string[] { group, avatar }); + } ProcessAvatar(avatar); if (avataruuid == UUID.Zero) { @@ -270,10 +280,6 @@ namespace BetterSecondBot.HttpService { return Failure("Unable to process role UUID", "GroupInvite", new string[] { group, avatar, role }); } - if(bot.MyGroups.ContainsKey(groupuuid) == false) - { - return Failure("Group missing from MyGroups", "GroupInvite", new string[] { group, avatar, role }); - } Group G = bot.MyGroups[groupuuid]; if(G.Powers.HasFlag(GroupPowers.Invite) == false) { @@ -315,6 +321,11 @@ namespace BetterSecondBot.HttpService { return Failure("Message empty", "Groupnotice", new string[] { group, title, message }); } + Group G = bot.MyGroups[groupuuid]; + if (G.Powers.HasFlag(GroupPowers.SendNotices) == false) + { + return Failure("Missing group notice power", "Groupnotice", new string[] { group, title, message }); + } GroupNotice NewNotice = new GroupNotice(); NewNotice.Subject = title; NewNotice.Message = message; @@ -415,6 +426,11 @@ namespace BetterSecondBot.HttpService { return Failure("Message empty", "GroupnoticeWithAttachment", new string[] { group, title, message, attachment }); } + Group G = bot.MyGroups[groupuuid]; + if (G.Powers.HasFlag(GroupPowers.SendNotices) == false) + { + return Failure("Missing group notice power", "GroupnoticeWithAttachment", new string[] { group, title, message, attachment }); + } GroupNotice NewNotice = new GroupNotice(); NewNotice.Subject = title; NewNotice.Message = message; @@ -599,6 +615,11 @@ namespace BetterSecondBot.HttpService { return Failure("Unknown group", "Groupchat", new string[] { group, message }); } + Group G = bot.MyGroups[groupUUID]; + if (G.Powers.HasFlag(GroupPowers.JoinChat) == false) + { + return Failure("Missing group JoinChat power", "Groupchat", new string[] { group, message }); + } if (bot.GetActiveGroupchatSessions.Contains(groupUUID) == false) { bot.GetClient.Self.RequestJoinGroupChat(groupUUID);