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
1
[Plugin(1, "Bot Viewer Extension Plugin", "Test plugin to showcase bot viewer possible extensions using chat command invocations.")]
2
public class PluginCore : IStartPlugin
3
{
4
public override void OnLoad(int version, int subversion, int buildversion) { }
5
public override PluginResponse OnEnable(IBotSettings botSettings) { return base.OnEnable(botSettings); }
6
}
7
8
public class ExampleChatHandler : IBotServerChatHandler {
9
public override string Name { get; set; } = "test";
10
public override string Description { get; set; } = "This is a test chat command handler for OQMineBot's bot server.";
11
public override string[] RequiredArguments { get; set; } = {"none|all", "opt|opt2|opt3" };
12
public override string[] OptionalArguments { get; set; } = { "greet|insult" };
13
14
public override ChatHandlerResult Execute(IBotContext Context, IConnectedClient Client, IBotServerEvents Events, string[] arguments) {
15
16
// Sanity checks.
17
if (arguments.Length < 1) return new ChatHandlerResult(false, "Argument not found.");
18
var argument = arguments[0].ToLower();
19
if (argument != "none" && argument != "all") return new ChatHandlerResult(false, "Invalid argument.");
20
21
/*
22
* Execute command here.
23
*/
24
25
return new ChatHandlerResult(true); // success
26
}
27
}
Copied!
Result from running the example code.
Last modified 1yr ago
Copy link