Minecraft-Console-Client/MinecraftClient/ChatBots/RemoteControl.cs
BruceChen 1d52d1eadd
Fix all warnings & Trim (#2226)
* Fix AutoFishing crash
* Fix all warnings
* Remove DotNetZip.
* Fix the usage of HttpClient.
2022-10-02 18:31:08 +08:00

37 lines
1.3 KiB
C#

using System;
namespace MinecraftClient.ChatBots
{
/// <summary>
/// Allow to perform operations using whispers to the bot
/// </summary>
public class RemoteControl : ChatBot
{
public override void GetText(string text)
{
text = GetVerbatim(text).Trim();
string command = "", sender = "";
if (IsPrivateMessage(text, ref command, ref sender) && Settings.Bots_Owners.Contains(sender.ToLower().Trim()))
{
string? response = "";
PerformInternalCommand(command, ref response);
response = GetVerbatim(response);
foreach (char disallowedChar in McClient.GetDisallowedChatCharacters())
{
response = response.Replace(disallowedChar.ToString(), String.Empty);
}
if (response.Length > 0)
{
SendPrivateMessage(sender, response);
}
}
else if (Settings.RemoteCtrl_AutoTpaccept
&& IsTeleportRequest(text, ref sender)
&& (Settings.RemoteCtrl_AutoTpaccept_Everyone || Settings.Bots_Owners.Contains(sender.ToLower().Trim())))
{
SendText("/tpaccept");
}
}
}
}