Chat Command Based Extension

These chat commands can be discovered through the !help command. Chat Command Based Extensions get invoked once the user sends a chat message with the desired keyword (Name variable).

PluginCore.cs

[Plugin(1, "Bot Viewer Extension Plugin", "Test plugin to showcase bot viewer possible extensions using chat command invocations.")]
public class PluginCore : IStartPlugin
{
    public override void OnLoad(int version, int subversion, int buildversion) { }
    public override PluginResponse OnEnable(IBotSettings botSettings) { return base.OnEnable(botSettings); }
}

public class ExampleChatHandler : IBotServerChatHandler {
    public override string Name { get; set; } = "test";
    public override string Description { get; set; } = "This is a test chat command handler for OQMineBot's bot server.";
    public override string[] RequiredArguments { get; set; } = {"none|all", "opt|opt2|opt3" };
    public override string[] OptionalArguments { get; set; } = { "greet|insult" };

    public override ChatHandlerResult Execute(IBotContext Context, IConnectedClient Client, IBotServerEvents Events, string[] arguments) {

        // Sanity checks.
        if (arguments.Length < 1) return new ChatHandlerResult(false, "Argument not found.");
        var argument = arguments[0].ToLower();
        if (argument != "none" && argument != "all") return new ChatHandlerResult(false, "Invalid argument.");

        /*
         * Execute command here.
         */

        return new ChatHandlerResult(true); // success
    }
}

Last updated