Remote Control : Auto accept tpa and tpahere

- Added Essentials teleportation request in bot api
- Used the api in remote control to auto accept
This commit is contained in:
ORelio 2014-06-14 13:51:30 +02:00
parent 9456e82923
commit f0b071ddea
2 changed files with 27 additions and 2 deletions

View file

@ -146,7 +146,7 @@ namespace MinecraftClient
}
/// <summary>
/// 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
/// </summary>
/// <param name="text">text to test</param>
/// <param name="message">if it's a private message, this will contain the message</param>
@ -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
}
/// <summary>
/// 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
/// </summary>
/// <param name="text">text to test</param>
/// <param name="message">if it's message, this will contain the message</param>
@ -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;
}
/// <summary>
/// Returns true if the text passed is a teleport request (Essentials)
/// </summary>
/// <param name="text">Text to parse</param>
/// <param name="sender">Will contain the sender's username, if it's a teleport request</param>
/// <returns>Returns true if the text is a teleport request</returns>
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;
}
/// <summary>
/// Writes some text in the console. Nothing will be sent to the server.
/// </summary>

View file

@ -46,6 +46,10 @@ namespace MinecraftClient.ChatBots
break;
}
}
else if (isTeleportRequest(text, ref sender) && Settings.Bots_Owners.Contains(sender.ToLower()))
{
SendText("/tpaccept");
}
}
}
}