Botting Command Additions

Plugins can also add custom commands to the botting tab. Regular plugin api functions can be used within the Activate method. This page describes how to make a plugin that registers new commands.

PluginCore.cs

[Plugin(1, "Extra Botting Command Plugin", "Adds new command to the botting tab!")]
public class PluginCore : IStartPlugin
{
    /// <summary>
    /// Should be used to check compatability with the
    /// current version of the bot.
    /// </summary>
    public override void OnLoad(int version, int subversion, int buildversion) { }
    public override PluginResponse OnEnable(IBotSettings botSettings) {
        /* Regular plugin content */
        return base.OnEnable(botSettings);
    }
}

public class TestCommand : IExternalCommand {
    public override string Name => "Test Command 1";
    public override string Description => "This is a description for the command.";

    public TestCommand() {
        this.Variables = new ICommandVariableCollection(
            new ExternalCommandVariable(typeof(string), "internal_variable_name", "Text to print", "What message should we send to the chat?", "This is a default message")
        );
    }

    public override CommandResponse Activate(IBotContext Context, ICommandVariables arguments, IStopToken token) {
        Context.Functions.Chat("Hello, my message is: " + arguments.Get<string>("internal_variable_name"));
        return new CommandResponse(); // no parameters means success=true
    }
}

Last updated