From a5fd7d60fd81af5ba5d75c4e7425c9dd00df379e Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 21 Jul 2022 13:40:07 +0100 Subject: [PATCH] Remove some legacy code --- core/bot.py | 34 ++++++++++------------ core/factory.py | 77 ------------------------------------------------- 2 files changed, 16 insertions(+), 95 deletions(-) delete mode 100644 core/factory.py diff --git a/core/bot.py b/core/bot.py index 4f20576..7edec16 100644 --- a/core/bot.py +++ b/core/bot.py @@ -731,9 +731,8 @@ class IRCBotFactory(ReconnectingClientFactory): self.relayCommands, self.user, self.stage2 = relayCommands, user, stage2 def buildProtocol(self, addr): - if self.relay is False: - entry = IRCBot(self.net, self.num) - main.IRCPool[self.name] = entry + entry = IRCBot(self.net, self.num) + main.IRCPool[self.name] = entry self.client = entry return entry @@ -746,21 +745,20 @@ class IRCBotFactory(ReconnectingClientFactory): self.client.authenticated = False self.client.channels = [] error = reason.getErrorMessage() - if not self.relay: - log("%s - %i: connection lost: %s" % (self.net, self.num, error)) - sendAll("%s - %i: connection lost: %s" % (self.net, self.num, error)) - ctime = str(datetime.now().isoformat()) - sendRelayNotification( - { - "type": "conn", - "net": self.net, - "num": self.num, - "status": "lost", - "message": error, - "ts": ctime, - } - ) - self.retry(connector) + log("%s - %i: connection lost: %s" % (self.net, self.num, error)) + sendAll("%s - %i: connection lost: %s" % (self.net, self.num, error)) + ctime = str(datetime.now().isoformat()) + sendRelayNotification( + { + "type": "conn", + "net": self.net, + "num": self.num, + "status": "lost", + "message": error, + "ts": ctime, + } + ) + self.retry(connector) # ReconnectingClientFactory.clientConnectionLost(self, connector, reason) def clientConnectionFailed(self, connector, reason): diff --git a/core/factory.py b/core/factory.py deleted file mode 100644 index 0d63e32..0000000 --- a/core/factory.py +++ /dev/null @@ -1,77 +0,0 @@ -class IRCBotFactory(ReconnectingClientFactory): - def __init__(self, net, num=None, relayCommands=None, user=None, stage2=None): - if net is None: - self.num = num - self.net = None - self.name = "relay - %i" % num - self.relay = True - else: - self.name = net + str(num) - self.num = num - self.net = net - self.relay = False - self.client = None - self.maxDelay = main.config["Tweaks"]["Delays"]["MaxDelay"] - self.initialDelay = main.config["Tweaks"]["Delays"]["InitialDelay"] - self.factor = main.config["Tweaks"]["Delays"]["Factor"] - self.jitter = main.config["Tweaks"]["Delays"]["Jitter"] - - self.relayCommands, self.user, self.stage2 = relayCommands, user, stage2 - - def buildProtocol(self, addr): - if self.relay is False: - entry = IRCBot(self.net, self.num) - main.IRCPool[self.name] = entry - else: - entry = IRCRelay(self.num, self.relayCommands, self.user, self.stage2) - - self.client = entry - return entry - - def clientConnectionLost(self, connector, reason): - if not self.relay: - userinfo.delChannels(self.net, self.client.channels) - if self.client is not None: - self.client.isconnected = False - self.client.authenticated = False - self.client.channels = [] - error = reason.getErrorMessage() - if not self.relay: - log("%s - %i: connection lost: %s" % (self.net, self.num, error)) - sendAll("%s - %i: connection lost: %s" % (self.net, self.num, error)) - ctime = str(datetime.now().isoformat()) - sendRelayNotification( - { - "type": "conn", - "net": self.net, - "num": self.num, - "status": "lost", - "message": error, - "ts": ctime, - } - ) - self.retry(connector) - # ReconnectingClientFactory.clientConnectionLost(self, connector, reason) - - def clientConnectionFailed(self, connector, reason): - if self.client is not None: - self.client.isconnected = False - self.client.authenticated = False - self.client.channels = [] - error = reason.getErrorMessage() - log("%s - %i: connection failed: %s" % (self.net, self.num, error)) - if not self.relay: - sendAll("%s - %s: connection failed: %s" % (self.net, self.num, error)) - ctime = str(datetime.now().isoformat()) - sendRelayNotification( - { - "type": "conn", - "net": self.net, - "num": self.num, - "status": "failed", - "message": error, - "ts": ctime, - } - ) - self.retry(connector) - # ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)