MineBot Plugin API
  • Introduction
  • Quick Start
  • Examples
    • Start Plugins
      • Events (basic)
      • Movement (basic)
      • Killaura (intermediate)
      • Wheat Farmer (intermediate)
    • Request Plugins
      • Chat (advanced)
    • Macro Component Additions
    • Botting Command Additions
    • BotViewer Additions
      • Base Extension
      • Chat Command Based Extension
  • API
    • ID System (Item & Block ids)
    • Events
    • Context
      • Player
      • Entities
        • IPlayerEntity
        • IMobEntity
        • IObjectEntity
      • World
        • IBlock
      • Containers
        • IWindow
        • ISlot
      • Functions
    • Utility
      • ChestMap
      • LocationBlacklistCollection
      • LocationWhitelistCollection
Powered by GitBook
On this page
  1. Examples
  2. BotViewer Additions

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
    }
}
PreviousBase ExtensionNextID System (Item & Block ids)

Last updated 5 years ago

Result from running the example code.