Remove some legacy code
This commit is contained in:
parent
f4c5323de1
commit
a5fd7d60fd
34
core/bot.py
34
core/bot.py
|
@ -731,9 +731,8 @@ class IRCBotFactory(ReconnectingClientFactory):
|
||||||
self.relayCommands, self.user, self.stage2 = relayCommands, user, stage2
|
self.relayCommands, self.user, self.stage2 = relayCommands, user, stage2
|
||||||
|
|
||||||
def buildProtocol(self, addr):
|
def buildProtocol(self, addr):
|
||||||
if self.relay is False:
|
entry = IRCBot(self.net, self.num)
|
||||||
entry = IRCBot(self.net, self.num)
|
main.IRCPool[self.name] = entry
|
||||||
main.IRCPool[self.name] = entry
|
|
||||||
|
|
||||||
self.client = entry
|
self.client = entry
|
||||||
return entry
|
return entry
|
||||||
|
@ -746,21 +745,20 @@ class IRCBotFactory(ReconnectingClientFactory):
|
||||||
self.client.authenticated = False
|
self.client.authenticated = False
|
||||||
self.client.channels = []
|
self.client.channels = []
|
||||||
error = reason.getErrorMessage()
|
error = reason.getErrorMessage()
|
||||||
if not self.relay:
|
log("%s - %i: connection lost: %s" % (self.net, self.num, error))
|
||||||
log("%s - %i: connection lost: %s" % (self.net, self.num, error))
|
sendAll("%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())
|
||||||
ctime = str(datetime.now().isoformat())
|
sendRelayNotification(
|
||||||
sendRelayNotification(
|
{
|
||||||
{
|
"type": "conn",
|
||||||
"type": "conn",
|
"net": self.net,
|
||||||
"net": self.net,
|
"num": self.num,
|
||||||
"num": self.num,
|
"status": "lost",
|
||||||
"status": "lost",
|
"message": error,
|
||||||
"message": error,
|
"ts": ctime,
|
||||||
"ts": ctime,
|
}
|
||||||
}
|
)
|
||||||
)
|
self.retry(connector)
|
||||||
self.retry(connector)
|
|
||||||
# ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
|
# ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
|
||||||
|
|
||||||
def clientConnectionFailed(self, connector, reason):
|
def clientConnectionFailed(self, connector, reason):
|
||||||
|
|
|
@ -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)
|
|
Loading…
Reference in New Issue