forked from ChomeNS/chomens-bot-java
fix the fix
This commit is contained in:
parent
e9c510588a
commit
76b4885c1c
1 changed files with 10 additions and 6 deletions
|
@ -45,7 +45,7 @@ public class DiscordPlugin {
|
|||
|
||||
public final String discordUrl;
|
||||
|
||||
private int totalConnects = 0;
|
||||
private final Map<String, Integer> totalConnects = new HashMap<>();
|
||||
|
||||
public boolean shuttedDown = false;
|
||||
|
||||
|
@ -70,6 +70,8 @@ public class DiscordPlugin {
|
|||
for (Bot bot : Main.bots) {
|
||||
final String channelId = servers.get(bot.host + ":" + bot.port);
|
||||
|
||||
totalConnects.put(channelId, 0); // is this necessary?
|
||||
|
||||
bot.addListener(new Bot.Listener() {
|
||||
@Override
|
||||
public void loadedPlugins() {
|
||||
|
@ -106,10 +108,12 @@ public class DiscordPlugin {
|
|||
|
||||
@Override
|
||||
public void connecting() {
|
||||
totalConnects++;
|
||||
final int newTotalConnects = totalConnects.get(channelId) + 1;
|
||||
|
||||
if (totalConnects > 20) return;
|
||||
else if (totalConnects == 20) {
|
||||
totalConnects.put(channelId, newTotalConnects);
|
||||
|
||||
if (newTotalConnects > 20) return;
|
||||
else if (newTotalConnects == 20) {
|
||||
sendMessageInstantly("Suspending connecting and disconnect messages from now on", channelId);
|
||||
|
||||
return;
|
||||
|
@ -127,7 +131,7 @@ public class DiscordPlugin {
|
|||
|
||||
@Override
|
||||
public void connected (ConnectedEvent event) {
|
||||
totalConnects = 0;
|
||||
totalConnects.put(channelId, 0);
|
||||
|
||||
sendMessageInstantly(
|
||||
String.format(
|
||||
|
@ -141,7 +145,7 @@ public class DiscordPlugin {
|
|||
|
||||
@Override
|
||||
public void disconnected(DisconnectedEvent event) {
|
||||
if (totalConnects >= 20) return;
|
||||
if (totalConnects.get(channelId) >= 20) return;
|
||||
|
||||
final String reason = ComponentUtilities.stringifyAnsi(event.getReason());
|
||||
sendMessageInstantly(
|
||||
|
|
Loading…
Reference in a new issue