From f0b071ddea3ea6349732f08ed5f12e5076daff18 Mon Sep 17 00:00:00 2001 From: ORelio Date: Sat, 14 Jun 2014 13:51:30 +0200 Subject: [PATCH] Remote Control : Auto accept tpa and tpahere - Added Essentials teleportation request in bot api - Used the api in remote control to auto accept --- MinecraftClient/ChatBot.cs | 25 +++++++++++++++++++++-- MinecraftClient/ChatBots/RemoteControl.cs | 4 ++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs index bdd7c4cc..61e9b244 100644 --- a/MinecraftClient/ChatBot.cs +++ b/MinecraftClient/ChatBot.cs @@ -146,7 +146,7 @@ namespace MinecraftClient } /// - /// Returns true is the text passed is a private message sent to the bot + /// Returns true if the text passed is a private message sent to the bot /// /// text to test /// if it's a private message, this will contain the message @@ -155,6 +155,7 @@ namespace MinecraftClient protected static bool isPrivateMessage(string text, ref string message, ref string sender) { + text = getVerbatim(text); if (text == "") { return false; } string[] tmp = text.Split(' '); @@ -190,7 +191,7 @@ namespace MinecraftClient } /// - /// Returns true is the text passed is a public message written by a player on the chat + /// Returns true if the text passed is a public message written by a player on the chat /// /// text to test /// if it's message, this will contain the message @@ -204,6 +205,7 @@ namespace MinecraftClient //<*Faction Someone> message //<*Faction Someone>: message //<*Faction ~Nicknamed>: message + text = getVerbatim(text); if (text == "") { return false; } if (text[0] == '<') { @@ -225,6 +227,25 @@ namespace MinecraftClient else return false; } + /// + /// Returns true if the text passed is a teleport request (Essentials) + /// + /// Text to parse + /// Will contain the sender's username, if it's a teleport request + /// Returns true if the text is a teleport request + + protected static bool isTeleportRequest(string text, ref string sender) + { + text = getVerbatim(text); + sender = text.Split(' ')[0]; + if (text.EndsWith("has requested to teleport to you.") + || text.EndsWith("has requested that you teleport to them.")) + { + return isValidName(sender); + } + else return false; + } + /// /// Writes some text in the console. Nothing will be sent to the server. /// diff --git a/MinecraftClient/ChatBots/RemoteControl.cs b/MinecraftClient/ChatBots/RemoteControl.cs index 44abdb12..cc66d412 100644 --- a/MinecraftClient/ChatBots/RemoteControl.cs +++ b/MinecraftClient/ChatBots/RemoteControl.cs @@ -46,6 +46,10 @@ namespace MinecraftClient.ChatBots break; } } + else if (isTeleportRequest(text, ref sender) && Settings.Bots_Owners.Contains(sender.ToLower())) + { + SendText("/tpaccept"); + } } } }