2014-05-31 01:59:03 +02:00
|
|
|
|
using System;
|
2022-10-05 15:02:30 +08:00
|
|
|
|
using Tomlet.Attributes;
|
2014-05-31 01:59:03 +02:00
|
|
|
|
|
|
|
|
|
|
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() { }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2014-05-31 01:59:03 +02:00
|
|
|
|
public override void GetText(string text)
|
|
|
|
|
|
{
|
2022-09-07 11:32:38 +02:00
|
|
|
|
text = GetVerbatim(text).Trim();
|
2014-05-31 01:59:03 +02:00
|
|
|
|
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()))
|
2014-05-31 01:59:03 +02:00
|
|
|
|
{
|
2022-10-02 18:31:08 +08:00
|
|
|
|
string? response = "";
|
2015-06-20 22:58:18 +02:00
|
|
|
|
PerformInternalCommand(command, ref response);
|
2021-05-13 01:34:55 +08:00
|
|
|
|
response = GetVerbatim(response);
|
|
|
|
|
|
foreach (char disallowedChar in McClient.GetDisallowedChatCharacters())
|
|
|
|
|
|
{
|
|
|
|
|
|
response = response.Replace(disallowedChar.ToString(), String.Empty);
|
|
|
|
|
|
}
|
2014-06-14 18:48:43 +02:00
|
|
|
|
if (response.Length > 0)
|
2014-05-31 01:59:03 +02:00
|
|
|
|
{
|
2014-06-14 18:48:43 +02:00
|
|
|
|
SendPrivateMessage(sender, response);
|
2014-05-31 01:59:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-10-05 15:02:30 +08:00
|
|
|
|
else if (Config.AutoTpaccept
|
2015-06-20 22:58:18 +02:00
|
|
|
|
&& IsTeleportRequest(text, ref sender)
|
2022-10-05 15:02:30 +08:00
|
|
|
|
&& (Config.AutoTpaccept_Everyone || Settings.Config.Main.Advanced.BotOwners.Contains(sender.ToLower().Trim())))
|
2014-06-14 13:51:30 +02:00
|
|
|
|
{
|
|
|
|
|
|
SendText("/tpaccept");
|
|
|
|
|
|
}
|
2014-05-31 01:59:03 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|