This commit is contained in:
BruceChen 2022-12-11 16:30:45 +08:00
parent 127978615c
commit 94a3c92b36
62 changed files with 371 additions and 297 deletions

View file

@ -257,12 +257,12 @@ namespace MinecraftClient.ChatBots
mailDbFileMonitor = new FileMonitor(Path.GetDirectoryName(Config.DatabaseFile)!, Path.GetFileName(Config.DatabaseFile), FileMonitorCallback);
ignoreListFileMonitor = new FileMonitor(Path.GetDirectoryName(Config.IgnoreListFile)!, Path.GetFileName(Config.IgnoreListFile), FileMonitorCallback);
Handler.dispatcher.Register(l => l.Literal("help")
McClient.dispatcher.Register(l => l.Literal("help")
.Then(l => l.Literal(CommandName)
.Executes(r => OnCommandHelp(string.Empty)))
);
Handler.dispatcher.Register(l => l.Literal(CommandName)
McClient.dispatcher.Register(l => l.Literal(CommandName)
.Then(l => l.Literal("getmails")
.Executes(r => OnCommandGetMails()))
.Then(l => l.Literal("getignored")
@ -274,14 +274,14 @@ namespace MinecraftClient.ChatBots
.Then(l => l.Argument("username", Arguments.String())
.Executes(r => OnCommandRemoveIgnored(Arguments.GetString(r, "username")))))
.Then(l => l.Literal("_help")
.Redirect(Handler.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
.Redirect(McClient.dispatcher.GetRoot().GetChild("help").GetChild(CommandName)))
);
}
public override void OnUnload()
{
Handler.dispatcher.Unregister(CommandName);
Handler.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
McClient.dispatcher.Unregister(CommandName);
McClient.dispatcher.GetRoot().GetChild("help").RemoveChild(CommandName);
}
private int OnCommandHelp(string cmd)
@ -290,7 +290,7 @@ namespace MinecraftClient.ChatBots
{
#pragma warning disable format // @formatter:off
_ => Translations.bot_mailer_cmd_help + ": /mailer <getmails|addignored|getignored|removeignored>"
+ '\n' + Handler.dispatcher.GetAllUsageString(CommandName, false),
+ '\n' + McClient.dispatcher.GetAllUsageString(CommandName, false),
#pragma warning restore format // @formatter:on
});
return 1;