Update Group.cs

adds power checks and messages for group commands
This commit is contained in:
Madpeterz 2021-03-23 00:03:54 +00:00
parent 87ad36e2cf
commit eb09fcb3bd

View file

@ -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);