mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
- MCC internal commands for command prompt, remote control and scripts are handled in one place, thus it's no more needed to add them in 3 different places. - "exit" command in scripts is not equivalent to "/quit" - removed "disconnect" command in scripts /!\ - bots can now easily perform internal MCC commands.
51 lines
2.4 KiB
C#
51 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
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);
|
|
string command = "", sender = "";
|
|
if (isPrivateMessage(text, ref command, ref sender) && Settings.Bots_Owners.Contains(sender.ToLower()))
|
|
{
|
|
string cmd_name = command.Split(' ')[0];
|
|
switch (cmd_name.ToLower())
|
|
{
|
|
case "help":
|
|
if (command.Length >= 6)
|
|
{
|
|
string help_cmd_name = command.Substring(5).ToLower();
|
|
switch (help_cmd_name)
|
|
{
|
|
case "exit": SendPrivateMessage(sender, "exit: disconnect from the server."); break;
|
|
case "reco": SendPrivateMessage(sender, "reco: restart and reconnct to the server."); break;
|
|
case "script": SendPrivateMessage(sender, "script <scriptname>: run a script file."); break;
|
|
case "send": SendPrivateMessage(sender, "send <text>: send a chat message or command."); break;
|
|
case "connect": SendPrivateMessage(sender, "connect <serverip>: connect to the specified server."); break;
|
|
case "help": SendPrivateMessage(sender, "help <cmdname>: show brief help about a command."); break;
|
|
default: SendPrivateMessage(sender, "help: unknown command '" + help_cmd_name + "'."); break;
|
|
}
|
|
}
|
|
else SendPrivateMessage(sender, "help <cmdname>. Available commands: exit, reco, script, send, connect.");
|
|
break;
|
|
default:
|
|
if (isInternalCommand(command))
|
|
{
|
|
performInternalCommand(command);
|
|
}
|
|
else SendPrivateMessage(sender, "Unknown command '" + cmd_name + "'. Use 'help' for help.");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|