Minecraft-Console-Client/MinecraftClient/ChatBots/RemoteControl.cs

50 lines
1.5 KiB
C#
Raw Normal View History

using System;
using MinecraftClient.CommandHandler;
using MinecraftClient.Scripting;
2022-10-05 15:02:30 +08:00
using Tomlet.Attributes;
namespace MinecraftClient.ChatBots
{
/// <summary>
/// Allow to perform operations using whispers to the bot
/// </summary>
public class RemoteControl : ChatBot
{
2022-10-05 15:02:30 +08:00
public static Configs Config = new();
[TomlDoNotInlineObject]
public class Configs
{
[NonSerialized]
private const string BotName = "RemoteControl";
public bool Enabled = false;
public bool AutoTpaccept = true;
public bool AutoTpaccept_Everyone = false;
public void OnSettingUpdate() { }
}
public override void GetText(string text)
{
2022-09-07 11:32:38 +02:00
text = GetVerbatim(text).Trim();
string command = "", sender = "";
2022-10-05 15:02:30 +08:00
if (IsPrivateMessage(text, ref command, ref sender) && Settings.Config.Main.Advanced.BotOwners.Contains(sender.ToLower().Trim()))
{
CmdResult response = new();
PerformInternalCommand(command, ref response);
SendPrivateMessage(sender, response.ToString());
}
2022-10-05 15:02:30 +08:00
else if (Config.AutoTpaccept
&& IsTeleportRequest(text, ref sender)
2022-10-05 15:02:30 +08:00
&& (Config.AutoTpaccept_Everyone || Settings.Config.Main.Advanced.BotOwners.Contains(sender.ToLower().Trim())))
{
SendText("/tpaccept");
}
}
}
}