Update Group.cs
adds power checks and messages for group commands
This commit is contained in:
parent
87ad36e2cf
commit
eb09fcb3bd
1 changed files with 25 additions and 4 deletions
|
|
@ -118,6 +118,11 @@ namespace BetterSecondBot.HttpService
|
||||||
{
|
{
|
||||||
return Failure("Unknown group", "GroupBan", new string[] { group, avatar, state });
|
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)
|
if (bool.TryParse(state, out bool banstate) == false)
|
||||||
{
|
{
|
||||||
return Failure("Invaild ban state", "GroupBan", new string[] { group, avatar, state });
|
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 });
|
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);
|
ProcessAvatar(avatar);
|
||||||
if (avataruuid == UUID.Zero)
|
if (avataruuid == UUID.Zero)
|
||||||
{
|
{
|
||||||
|
|
@ -270,10 +280,6 @@ namespace BetterSecondBot.HttpService
|
||||||
{
|
{
|
||||||
return Failure("Unable to process role UUID", "GroupInvite", new string[] { group, avatar, role });
|
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];
|
Group G = bot.MyGroups[groupuuid];
|
||||||
if(G.Powers.HasFlag(GroupPowers.Invite) == false)
|
if(G.Powers.HasFlag(GroupPowers.Invite) == false)
|
||||||
{
|
{
|
||||||
|
|
@ -315,6 +321,11 @@ namespace BetterSecondBot.HttpService
|
||||||
{
|
{
|
||||||
return Failure("Message empty", "Groupnotice", new string[] { group, title, message });
|
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();
|
GroupNotice NewNotice = new GroupNotice();
|
||||||
NewNotice.Subject = title;
|
NewNotice.Subject = title;
|
||||||
NewNotice.Message = message;
|
NewNotice.Message = message;
|
||||||
|
|
@ -415,6 +426,11 @@ namespace BetterSecondBot.HttpService
|
||||||
{
|
{
|
||||||
return Failure("Message empty", "GroupnoticeWithAttachment", new string[] { group, title, message, attachment });
|
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();
|
GroupNotice NewNotice = new GroupNotice();
|
||||||
NewNotice.Subject = title;
|
NewNotice.Subject = title;
|
||||||
NewNotice.Message = message;
|
NewNotice.Message = message;
|
||||||
|
|
@ -599,6 +615,11 @@ namespace BetterSecondBot.HttpService
|
||||||
{
|
{
|
||||||
return Failure("Unknown group", "Groupchat", new string[] { group, message });
|
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)
|
if (bot.GetActiveGroupchatSessions.Contains(groupUUID) == false)
|
||||||
{
|
{
|
||||||
bot.GetClient.Self.RequestJoinGroupChat(groupUUID);
|
bot.GetClient.Self.RequestJoinGroupChat(groupUUID);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue