Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Tikuf 2020-04-25 19:25:36 -06:00
commit 647c4f9ae3
3 changed files with 19 additions and 13 deletions

View file

@ -202,16 +202,16 @@ namespace BSB.Commands
protected List<string> suppress_warnings = new List<string>(); protected List<string> suppress_warnings = new List<string>();
public bool Call(string command) public bool Call(string command)
{ {
return Call(command, ""); return Call(command, "",UUID.Zero);
} }
protected bool CallCommand(string command, string arg) protected bool CallCommand(string command, string arg, UUID caller)
{ {
command = command.ToLowerInvariant(); command = command.ToLowerInvariant();
CoreCommand cmd = (CoreCommand)GetCommand(command); CoreCommand cmd = (CoreCommand)GetCommand(command);
if (cmd != null) if (cmd != null)
{ {
cmd.Setup(bot); cmd.Setup(bot, caller);
if ((cmd.ArgTypes.Contains("Avatar") == true) || (cmd.ArgTypes.Contains("Smart") == true)) if ((cmd.ArgTypes.Contains("Avatar") == true) || (cmd.ArgTypes.Contains("Smart") == true))
{ {
string[] args = arg.Split(new string[] { "~#~" }, StringSplitOptions.None); string[] args = arg.Split(new string[] { "~#~" }, StringSplitOptions.None);
@ -255,9 +255,9 @@ namespace BSB.Commands
} }
} }
public bool Call(string command, string arg) public bool Call(string command, string arg,UUID caller)
{ {
bool result = CallCommand(command, arg); bool result = CallCommand(command, arg, caller);
bot.CommandHistoryAdd(command, arg, result); bot.CommandHistoryAdd(command, arg, result);
return result; return result;
} }
@ -265,9 +265,15 @@ namespace BSB.Commands
public abstract class CoreCommand : API_interface public abstract class CoreCommand : API_interface
{ {
protected CommandsBot bot = null; protected CommandsBot bot = null;
public void Setup(CommandsBot setBot)
/// <summary>
/// The UUID of the object/Avatar that called this function, you should still test if its not UUID zero and is a avatar
/// </summary>
protected UUID caller = UUID.Zero;
public void Setup(CommandsBot setBot,UUID setCaller)
{ {
bot = setBot; bot = setBot;
caller = setCaller;
} }
public virtual void Callback(string[] args, EventArgs e,bool status) public virtual void Callback(string[] args, EventArgs e,bool status)
{ {

View file

@ -96,9 +96,9 @@ namespace BSB.bottypes
} }
} }
protected virtual void CallCommandLib(string command, string arg) protected virtual void CallCommandLib(string command, string arg, UUID caller)
{ {
CommandsInterface.Call(command, arg); CommandsInterface.Call(command, arg, caller);
} }
protected override void AfterBotLoginHandler() protected override void AfterBotLoginHandler()
@ -120,12 +120,12 @@ namespace BSB.bottypes
string hashcheck = helpers.GetSHA1(raw); string hashcheck = helpers.GetSHA1(raw);
if (hashcheck == signing_code) if (hashcheck == signing_code)
{ {
CallCommandLib(command, arg); CallCommandLib(command, arg, fromUUID);
} }
} }
else if (from_master == true) else if (from_master == true)
{ {
CallCommandLib(command, arg); CallCommandLib(command, arg, fromUUID);
} }
} }
} }

View file

@ -424,7 +424,7 @@ namespace BSB.bottypes
bool status = false; bool status = false;
if (bits.Length == 2) if (bits.Length == 2)
{ {
status = CommandsInterface.Call(command, bits[1]); status = CommandsInterface.Call(command, bits[1],UUID.Zero);
} }
else else
{ {
@ -500,11 +500,11 @@ namespace BSB.bottypes
} }
Noticetitle = Noticetitle.Replace("!notice ", ""); Noticetitle = Noticetitle.Replace("!notice ", "");
Noticetitle = Noticetitle.Trim(); Noticetitle = Noticetitle.Trim();
CommandsInterface.Call("GroupNotice", ""+ group.ToString()+"~#~" + Noticetitle + "~#~" + Noticemessage); CommandsInterface.Call("GroupNotice", ""+ group.ToString()+"~#~" + Noticetitle + "~#~" + Noticemessage,UUID.Zero);
} }
else else
{ {
CommandsInterface.Call("Groupchat", "" + group.ToString() + "~#~" + "[" + message.Author.Username + "]->" + message.Content); CommandsInterface.Call("Groupchat", "" + group.ToString() + "~#~" + "[" + message.Author.Username + "]->" + message.Content, UUID.Zero);
} }
await message.DeleteAsync(); await message.DeleteAsync();
} }