mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Fix AutoRelog running twice on disconnection
Bug introduced in commit aaf1e8311b
Implement User-Initiated logout reason to ignore the second logout event
See #817
This commit is contained in:
parent
94e96b11dd
commit
52d98538b3
3 changed files with 35 additions and 24 deletions
|
|
@ -58,29 +58,37 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
public override bool OnDisconnect(DisconnectReason reason, string message)
|
||||
{
|
||||
message = GetVerbatim(message);
|
||||
string comp = message.ToLower();
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
LogToConsole("Got disconnected with message: " + message);
|
||||
|
||||
foreach (string msg in dictionary)
|
||||
if (reason == DisconnectReason.UserLogout)
|
||||
{
|
||||
if (comp.Contains(msg))
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
LogToConsole("Message contains '" + msg + "'. Reconnecting.");
|
||||
|
||||
LogToConsole("Waiting " + delay + " seconds before reconnecting...");
|
||||
System.Threading.Thread.Sleep(delay * 1000);
|
||||
McTcpClient.ReconnectionAttemptsLeft = attempts;
|
||||
ReconnectToTheServer();
|
||||
return true;
|
||||
}
|
||||
if (Settings.DebugMessages)
|
||||
LogToConsole("Ignoring disconnection initiated by User or MCC bot");
|
||||
}
|
||||
else
|
||||
{
|
||||
message = GetVerbatim(message);
|
||||
string comp = message.ToLower();
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
LogToConsole("Message not containing any defined keywords. Ignoring.");
|
||||
if (Settings.DebugMessages)
|
||||
LogToConsole("Got disconnected with message: " + message);
|
||||
|
||||
foreach (string msg in dictionary)
|
||||
{
|
||||
if (comp.Contains(msg))
|
||||
{
|
||||
if (Settings.DebugMessages)
|
||||
LogToConsole("Message contains '" + msg + "'. Reconnecting.");
|
||||
|
||||
LogToConsole("Waiting " + delay + " seconds before reconnecting...");
|
||||
System.Threading.Thread.Sleep(delay * 1000);
|
||||
McTcpClient.ReconnectionAttemptsLeft = attempts;
|
||||
ReconnectToTheServer();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.DebugMessages)
|
||||
LogToConsole("Message not containing any defined keywords. Ignoring.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue