mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
[skipci] Add an IP lookup to the WebSocketBot
Add an IP lookup to the WebSocketBot
This commit is contained in:
commit
21e2f41f25
4 changed files with 2020 additions and 1993 deletions
|
|
@ -287,13 +287,21 @@ public class WebSocketBot : ChatBot
|
||||||
|
|
||||||
[TomlInlineComment("$ChatBot.WebSocketBot.DebugMode$")]
|
[TomlInlineComment("$ChatBot.WebSocketBot.DebugMode$")]
|
||||||
public bool DebugMode = false;
|
public bool DebugMode = false;
|
||||||
|
|
||||||
|
[TomlInlineComment("$ChatBot.WebSocketBot.AllowIpAlias$")]
|
||||||
|
public bool AllowIpAlias = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WebSocketBot()
|
public WebSocketBot()
|
||||||
{
|
{
|
||||||
|
_password = Config.Password;
|
||||||
|
_authenticatedSessions = new();
|
||||||
|
_waitingEvents = new();
|
||||||
|
|
||||||
var match = Regex.Match(Config.Ip!, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}");
|
var match = Regex.Match(Config.Ip!, @"\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}");
|
||||||
|
|
||||||
if (!match.Success)
|
// If AllowIpAlias is set to true in the config, then always ignore this check
|
||||||
|
if (!match.Success & !Config.AllowIpAlias!)
|
||||||
{
|
{
|
||||||
LogToConsole(Translations.bot_WebSocketBot_failed_to_start_ip);
|
LogToConsole(Translations.bot_WebSocketBot_failed_to_start_ip);
|
||||||
return;
|
return;
|
||||||
|
|
@ -307,9 +315,6 @@ public class WebSocketBot : ChatBot
|
||||||
|
|
||||||
_ip = Config.Ip;
|
_ip = Config.Ip;
|
||||||
_port = Config.Port;
|
_port = Config.Port;
|
||||||
_password = Config.Password;
|
|
||||||
_authenticatedSessions = new();
|
|
||||||
_waitingEvents = new();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
|
|
|
||||||
|
|
@ -799,7 +799,8 @@ namespace MinecraftClient {
|
||||||
///NOTE: This is an experimental feature, the bot can be slow at times, you need to walk with a normal speed and to sometimes stop for it to be able to keep up with you
|
///NOTE: This is an experimental feature, the bot can be slow at times, you need to walk with a normal speed and to sometimes stop for it to be able to keep up with you
|
||||||
///It's similar to making animals follow you when you're holding food in your hand.
|
///It's similar to making animals follow you when you're holding food in your hand.
|
||||||
///This is due to a slow pathfinding algorithm, we're working on getting a better one
|
///This is due to a slow pathfinding algorithm, we're working on getting a better one
|
||||||
///You can tweak the update limit and find what works best for you. (NOTE: Do not but a very low one, because you might achieve the opposite,
/// [rest of string was truncated]";.
|
///You can tweak the update limit and find what works best for you. (NOTE: Do not but a very low one, because you might achieve the opposite,
|
||||||
|
/// [rest of string was truncated]";.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ChatBot_FollowPlayer {
|
internal static string ChatBot_FollowPlayer {
|
||||||
get {
|
get {
|
||||||
|
|
@ -1128,6 +1129,15 @@ namespace MinecraftClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Allow IP aliases, such as "localhost" or if using containers then the container name can be used...
|
||||||
|
/// </summary>
|
||||||
|
internal static string ChatBot_WebSocketBot_AllowIpAlias {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ChatBot.WebSocketBot.AllowIpAlias", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to This setting is for developers who are developing a library that uses this chat bot to remotely execute procedures/commands/functions..
|
/// Looks up a localized string similar to This setting is for developers who are developing a library that uses this chat bot to remotely execute procedures/commands/functions..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -843,6 +843,9 @@ If the connection to the Minecraft game server is blocked by the firewall, set E
|
||||||
<data name="ChatBot.WebSocketBot.DebugMode" xml:space="preserve">
|
<data name="ChatBot.WebSocketBot.DebugMode" xml:space="preserve">
|
||||||
<value>This setting is for developers who are developing a library that uses this chat bot to remotely execute procedures/commands/functions.</value>
|
<value>This setting is for developers who are developing a library that uses this chat bot to remotely execute procedures/commands/functions.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="ChatBot.WebSocketBot.AllowIpAlias" xml:space="preserve">
|
||||||
|
<value>Allow IP aliases, such as "localhost" or if using containers then the container name can be used...</value>
|
||||||
|
</data>
|
||||||
<data name="Main.Advanced.ignore_invalid_playername" xml:space="preserve">
|
<data name="Main.Advanced.ignore_invalid_playername" xml:space="preserve">
|
||||||
<value>Ignore invalid player name</value>
|
<value>Ignore invalid player name</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
||||||
|
|
@ -2451,6 +2451,15 @@ namespace MinecraftClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to .
|
||||||
|
/// </summary>
|
||||||
|
internal static string ChatBot_WebSocketBot_AllowIpAlias {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("ChatBot.WebSocketBot.AllowIpAlias", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to .
|
/// Looks up a localized string similar to .
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue