Tweaks to commands

adjusted chat commands to use isempty and use Failure replys.
group eject no longer checks if the user is in the group before ejecting
This commit is contained in:
Madpeterz 2021-03-06 17:24:11 +00:00
parent bd8dd13efd
commit 63c6baf4b8
3 changed files with 22 additions and 15 deletions

View file

@ -39,19 +39,19 @@ namespace BetterSecondBot.HttpService
{ {
if (tokens.Allow(token, "chat", "Say", handleGetClientIP()) == false) if (tokens.Allow(token, "chat", "Say", handleGetClientIP()) == false)
{ {
return BasicReply("Token not accepted"); return Failure("Token not accepted");
} }
if (helpers.notempty(message) == false) if (helpers.isempty(message) == true)
{ {
return BasicReply("Message empty"); return Failure("Message empty");
} }
if(int.TryParse(channel,out int channelnum) == false) if(int.TryParse(channel,out int channelnum) == false)
{ {
return BasicReply("Invaild channel"); return Failure("Invaild channel");
} }
if(channelnum < 0) if(channelnum < 0)
{ {
return BasicReply("Invaild channel"); return Failure("Invaild channel");
} }
bot.GetClient.Self.Chat(message, channelnum, ChatType.Normal); bot.GetClient.Self.Chat(message, channelnum, ChatType.Normal);
return BasicReply(JsonConvert.SerializeObject(bot.getLocalChatHistory())); return BasicReply(JsonConvert.SerializeObject(bot.getLocalChatHistory()));
@ -69,16 +69,16 @@ namespace BetterSecondBot.HttpService
{ {
if (tokens.Allow(token, "chat", "IM", handleGetClientIP()) == false) if (tokens.Allow(token, "chat", "IM", handleGetClientIP()) == false)
{ {
return BasicReply("Token not accepted"); return Failure("Token not accepted");
} }
ProcessAvatar(avatar); ProcessAvatar(avatar);
if(avataruuid == UUID.Zero) if(avataruuid == UUID.Zero)
{ {
return BasicReply("avatar lookup"); return Failure("avatar lookup");
} }
if (helpers.notempty(message) == false) if (helpers.isempty(message) == true)
{ {
return BasicReply("Message empty"); return Failure("Message empty");
} }
bot.SendIM(avataruuid, message); bot.SendIM(avataruuid, message);
return BasicReply("ok"); return BasicReply("ok");

View file

@ -164,11 +164,6 @@ namespace BetterSecondBot.HttpService
{ {
return Failure("avatar lookup"); return Failure("avatar lookup");
} }
bool status = bot.FastCheckInGroup(groupuuid, avataruuid);
if(status == false)
{
return BasicReply("Not in group");
}
bot.GetClient.Groups.EjectUser(groupuuid, avataruuid); bot.GetClient.Groups.EjectUser(groupuuid, avataruuid);
return BasicReply("Requested"); return BasicReply("Requested");
} }

View file

@ -246,8 +246,20 @@ namespace BetterSecondBotShared.Static
} }
} }
return false; return false;
} }
public static bool isempty(string V)
{
if (V != null)
{
if (V.Length > 0)
{
return false;
}
}
return true;
}
public static bool notempty(string[] V) public static bool notempty(string[] V)
{ {
if (V != null) if (V != null)