Revert "Added the Web Socket Chat Bot"

This commit is contained in:
BruceChen 2022-10-25 16:23:25 +08:00 committed by GitHub
parent 07b1f59285
commit 4925689496
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 4 additions and 1248 deletions

3
.gitmodules vendored
View file

@ -2,6 +2,3 @@
path = ConsoleInteractive
url = https://github.com/breadbyte/ConsoleInteractive
branch = main
[submodule "websocket-sharp"]
path = websocket-sharp
url = https://github.com/sta/websocket-sharp.git

View file

@ -313,7 +313,7 @@ namespace MinecraftClient.ChatBots
if (File.Exists(newFileName))
File.Delete(newFileName);
}
catch (IOException) { }
catch (IOException e) { }
}
});
}

File diff suppressed because it is too large Load diff

View file

@ -103,7 +103,7 @@ namespace MinecraftClient
&& IsHex(toparse[cursorpos + 5]))
{
//"abc\u0123abc" => "0123" => 0123 => Unicode char n°0123 => Add char to string
data.StringValue += char.ConvertFromUtf32(int.Parse(toparse.Substring(cursorpos + 2, 4),
data.StringValue += char.ConvertFromUtf32(int.Parse(toparse.Substring(cursorpos + 2, 4),
System.Globalization.NumberStyles.HexNumber));
cursorpos += 6; continue;
}
@ -221,60 +221,5 @@ namespace MinecraftClient
|| toparse[cursorpos] == '\n'))
cursorpos++;
}
// Original: https://github.com/mono/mono/blob/master/mcs/class/System.Json/System.Json/JsonValue.cs
private static bool NeedEscape(string src, int i)
{
char c = src[i];
return c < 32 || c == '"' || c == '\\'
// Broken lead surrogate
|| (c >= '\uD800' && c <= '\uDBFF' &&
(i == src.Length - 1 || src[i + 1] < '\uDC00' || src[i + 1] > '\uDFFF'))
// Broken tail surrogate
|| (c >= '\uDC00' && c <= '\uDFFF' &&
(i == 0 || src[i - 1] < '\uD800' || src[i - 1] > '\uDBFF'))
// To produce valid JavaScript
|| c == '\u2028' || c == '\u2029'
// Escape "</" for <script> tags
|| (c == '/' && i > 0 && src[i - 1] == '<');
}
public static string EscapeString(string src)
{
StringBuilder sb = new StringBuilder();
int start = 0;
for (int i = 0; i < src.Length; i++)
{
if (NeedEscape(src, i))
{
sb.Append(src, start, i - start);
switch (src[i])
{
case '\b': sb.Append("\\b"); break;
case '\f': sb.Append("\\f"); break;
case '\n': sb.Append("\\n"); break;
case '\r': sb.Append("\\r"); break;
case '\t': sb.Append("\\t"); break;
case '\"': sb.Append("\\\""); break;
case '\\': sb.Append("\\\\"); break;
case '/': sb.Append("\\/"); break;
default:
sb.Append("\\u");
sb.Append(((int)src[i]).ToString("x04"));
break;
}
start = i + 1;
}
}
sb.Append(src, start, src.Length - start);
return sb.ToString();
}
}
}

View file

@ -275,8 +275,6 @@ namespace MinecraftClient
if (Config.ChatBot.ReplayCapture.Enabled && reload) { BotLoad(new ReplayCapture()); }
if (Config.ChatBot.ScriptScheduler.Enabled) { BotLoad(new ScriptScheduler()); }
if (Config.ChatBot.TelegramBridge.Enabled) { BotLoad(new TelegramBridge()); }
if (Config.ChatBot.WebSocketBot.Enabled) { BotLoad(new WebSocketBot()); }
//Add your ChatBot here by uncommenting and adapting
//BotLoad(new ChatBots.YourBot());
}

View file

@ -41,7 +41,6 @@
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.1" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="6.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Samboy063.Tomlet" Version="5.0.0" />
<PackageReference Include="SingleFileExtractor.Core" Version="1.0.1" />
<PackageReference Include="starksoft.aspen" Version="1.1.8">
@ -76,7 +75,6 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConsoleInteractive\ConsoleInteractive\ConsoleInteractive\ConsoleInteractive.csproj" />
<ProjectReference Include="..\websocket-sharp\websocket-sharp\websocket-sharp.csproj" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="DefaultConfigResource.resx">

View file

@ -770,17 +770,6 @@ bot.TelegramBridge.direction.both=Both
bot.TelegramBridge.direction.minecraft=Minecraft
bot.TelegramBridge.direction.Telegram=Telegram
# WebSocketBot
bot.WebSocketBot.session_id_changed=§bSession with an id §a{0}§b has been renamed to: §a{1}§b!
bot.WebSocketBot.session_authenticated=§bSession with an id §a{0}§b has been succesfully authenticated!
bot.WebSocketBot.failed_to_start.ip=§cFailed to start a server! The provided IP address is not a valid one!
bot.WebSocketBot.failed_to_start.port=§cFailed to start a server! The port number provided is out of the range, it must be 65535 or bellow it!
bot.WebSocketBot.failed_to_start.custom=§cFailed to start a server:\n\n{0}\n\n
bot.WebSocketBot.starting=Starting the Websocket server...
bot.WebSocketBot.started=§bServer started on ip §a{0}§b port: §a{1}
bot.WebSocketBot.new_session=§bNew session connected: §a{0}
bot.WebSocketBot.session_disconnected=§bSession with an id §a{0}§b has disconnected!
# TestBot
botname.TestBot=TestBot
bot.testBot.told=Bot: {0} told me : {1}
@ -1040,11 +1029,4 @@ config.ChatBot.TelegramBridge.Token=Your Telegram Bot token.
config.ChatBot.TelegramBridge.ChannelId=An ID of a channel where you want to interact with the MCC using the bot.
config.ChatBot.TelegramBridge.Authorized_Chat_Ids=A list of Chat IDs that are allowed to send messages and execute commands. To get an id of your chat DM with the bot use ".chatid" bot command in Telegram.
config.ChatBot.TelegramBridge.MessageSendTimeout=How long to wait (in seconds) if a message can not be sent to Telegram before canceling the task (minimum 1 second).
config.ChatBot.TelegramBridge.Formats=Message formats\n# Words wrapped with { and } are going to be replaced during the code execution, do not change them!\n# For example. {message} is going to be replace with an actual message, {username} will be replaced with an username, {timestamp} with the current time.\n# For Telegram message formatting, check the following: https://sendpulse.com/blog/telegram-text-formatting
# ChatBot.WebSocketBot
config.ChatBot.WebSocketBot=Remotely control the client using Web Sockets.\n# This is useful if you want to implement an application that can remotely and asynchronously execute procedures in MCC.\n# Example implementation written in JavaScript: https://github.com/milutinke/MCC.js.git\n# The protocol specification will be available in the documentation soon.
config.ChatBot.WebSocketBot.Ip=The IP address that Websocket server will be bounded to.
config.ChatBot.WebSocketBot.Port=The Port that Websocket server will be bounded to.
config.ChatBot.WebSocketBot.Password=A password that will be used to authenticate on thw Websocket server (It is recommended to change the default password and to set a strong one).
config.ChatBot.WebSocketBot.DebugMode=If enabled the chat bot will print what is it recieving and sending when the "DebugMessages" are enabled in "Logging" section. This is useful when making your own library or trying to figure what is wrong with an existing one.
config.ChatBot.TelegramBridge.Formats=Message formats\n# Words wrapped with { and } are going to be replaced during the code execution, do not change them!\n# For example. {message} is going to be replace with an actual message, {username} will be replaced with an username, {timestamp} with the current time.\n# For Telegram message formatting, check the following: https://sendpulse.com/blog/telegram-text-formatting

View file

@ -1013,7 +1013,7 @@ namespace MinecraftClient
/// <summary>
/// Send Entity Action
/// </summary>
protected bool SendEntityAction(Protocol.EntityActionType entityAction)
private bool SendEntityAction(Protocol.EntityActionType entityAction)
{
return Handler.SendEntityAction(entityAction);
}

View file

@ -1170,13 +1170,6 @@ namespace MinecraftClient
get { return ChatBots.TelegramBridge.Config; }
set { ChatBots.TelegramBridge.Config = value; ChatBots.TelegramBridge.Config.OnSettingUpdate(); }
}
[TomlPrecedingComment("$config.ChatBot.WebSocketBot$")]
public ChatBots.WebSocketBot.Configs WebSocketBot
{
get { return ChatBots.WebSocketBot.Config!; }
set { ChatBots.WebSocketBot.Config = value; }
}
}
}

@ -1 +0,0 @@
Subproject commit 8e175845420d7dd707d7636747a71a0b5037ba91