adds support to access caller from within the commands lib
This commit is contained in:
parent
47246eb189
commit
5fbab6f118
3 changed files with 19 additions and 13 deletions
|
|
@ -202,16 +202,16 @@ namespace BSB.Commands
|
|||
protected List<string> suppress_warnings = new List<string>();
|
||||
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();
|
||||
CoreCommand cmd = (CoreCommand)GetCommand(command);
|
||||
if (cmd != null)
|
||||
{
|
||||
cmd.Setup(bot);
|
||||
cmd.Setup(bot, caller);
|
||||
if ((cmd.ArgTypes.Contains("Avatar") == true) || (cmd.ArgTypes.Contains("Smart") == true))
|
||||
{
|
||||
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);
|
||||
return result;
|
||||
}
|
||||
|
|
@ -265,9 +265,15 @@ namespace BSB.Commands
|
|||
public abstract class CoreCommand : API_interface
|
||||
{
|
||||
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;
|
||||
caller = setCaller;
|
||||
}
|
||||
public virtual void Callback(string[] args, EventArgs e,bool status)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
@ -120,12 +120,12 @@ namespace BSB.bottypes
|
|||
string hashcheck = helpers.GetSHA1(raw);
|
||||
if (hashcheck == signing_code)
|
||||
{
|
||||
CallCommandLib(command, arg);
|
||||
CallCommandLib(command, arg, fromUUID);
|
||||
}
|
||||
}
|
||||
else if (from_master == true)
|
||||
{
|
||||
CallCommandLib(command, arg);
|
||||
CallCommandLib(command, arg, fromUUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ namespace BSB.bottypes
|
|||
bool status = false;
|
||||
if (bits.Length == 2)
|
||||
{
|
||||
status = CommandsInterface.Call(command, bits[1]);
|
||||
status = CommandsInterface.Call(command, bits[1],UUID.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -500,11 +500,11 @@ namespace BSB.bottypes
|
|||
}
|
||||
Noticetitle = Noticetitle.Replace("!notice ", "");
|
||||
Noticetitle = Noticetitle.Trim();
|
||||
CommandsInterface.Call("GroupNotice", ""+ group.ToString()+"~#~" + Noticetitle + "~#~" + Noticemessage);
|
||||
CommandsInterface.Call("GroupNotice", ""+ group.ToString()+"~#~" + Noticetitle + "~#~" + Noticemessage,UUID.Zero);
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue