Implement authentication detection
* pending command to see which instances have never authenticated * authcheck command to see which instances are not currently authenticated
This commit is contained in:
21
core/bot.py
21
core/bot.py
@@ -108,7 +108,7 @@ class IRCRelay(IRCClient):
|
||||
def signedOn(self):
|
||||
if not self.isconnected:
|
||||
self.isconnected = True
|
||||
log("signed on as a relay: %s" % self.num)
|
||||
#log("signed on as a relay: %s" % self.num)
|
||||
sleeptime = 0
|
||||
increment = 0.8
|
||||
for i in self.relayCommands.keys():
|
||||
@@ -124,6 +124,7 @@ class IRCRelay(IRCClient):
|
||||
class IRCBot(IRCClient):
|
||||
def __init__(self, net, num):
|
||||
self.isconnected = False
|
||||
self.authenticated = False
|
||||
self.channels = []
|
||||
self.net = net
|
||||
self.num = num
|
||||
@@ -156,6 +157,8 @@ class IRCBot(IRCClient):
|
||||
self.chanlimit = 0
|
||||
self.servername = None
|
||||
|
||||
self._regAttempt = None
|
||||
|
||||
def lineReceived(self, line):
|
||||
if bytes != str and isinstance(line, bytes):
|
||||
# decode bytes from transport to unicode
|
||||
@@ -208,7 +211,7 @@ class IRCBot(IRCClient):
|
||||
return
|
||||
if not {"nick", "ident", "host"}.issubset(set(cast.keys())):
|
||||
cast["nick"], cast["ident"], cast["host"] = parsen(cast["muser"])
|
||||
if set(["nick", "ident", "host", "msg"]).issubset(set(cast)):
|
||||
if {"nick", "ident", "host", "msg"}.issubset(set(cast)):
|
||||
if "msg" in cast.keys():
|
||||
if cast["ident"] == "znc" and cast["host"] == "znc.in":
|
||||
cast["type"] = "znc"
|
||||
@@ -235,6 +238,7 @@ class IRCBot(IRCClient):
|
||||
# channel, but we still want to see them
|
||||
if "user" in cast.keys():
|
||||
if cast["user"].lower() == self.nickname.lower():
|
||||
cast["num"] = self.num
|
||||
castDup = deepcopy(cast)
|
||||
castDup["mtype"] = cast["type"]
|
||||
castDup["type"] = "self"
|
||||
@@ -242,6 +246,7 @@ class IRCBot(IRCClient):
|
||||
self.event(**castDup)
|
||||
if "nick" in cast.keys():
|
||||
if cast["nick"].lower() == self.nickname.lower():
|
||||
cast["num"] = self.num
|
||||
castDup = deepcopy(cast)
|
||||
castDup["mtype"] = cast["type"]
|
||||
castDup["type"] = "self"
|
||||
@@ -251,6 +256,7 @@ class IRCBot(IRCClient):
|
||||
if "msg" in cast.keys() and not cast["type"] == "query": # Don't highlight queries
|
||||
if not cast["msg"] == None:
|
||||
if self.nickname.lower() in cast["msg"].lower():
|
||||
cast["num"] = self.num
|
||||
castDup = deepcopy(cast)
|
||||
castDup["mtype"] = cast["type"]
|
||||
castDup["type"] = "highlight"
|
||||
@@ -259,6 +265,9 @@ class IRCBot(IRCClient):
|
||||
|
||||
if not "net" in cast.keys():
|
||||
cast["net"] = self.net
|
||||
if not "num" in cast.keys():
|
||||
print("no num", cast)
|
||||
cast["num"] = self.num
|
||||
counters.event(self.net, cast["type"])
|
||||
monitor.event(self.net, cast)
|
||||
|
||||
@@ -474,8 +483,8 @@ class IRCBot(IRCClient):
|
||||
self.isconnected = True
|
||||
if not main.network[self.net].relays[self.num]["registered"]:
|
||||
if main.config["AutoReg"]:
|
||||
regproc.registerAccount(self.net, self.num)
|
||||
debug("Attempting to register: %s - %i" % (self.net, self.num))
|
||||
self._regAttempt = reactor.callLater(5, regproc.registerAccount, self.net, self.num)
|
||||
#regproc.registerAccount(self.net, self.num)
|
||||
for i in options:
|
||||
if i.startswith("CHANLIMIT"):
|
||||
if ":" in i:
|
||||
@@ -669,10 +678,11 @@ class IRCBotFactory(ReconnectingClientFactory):
|
||||
userinfo.delChannels(self.net, self.client.channels)
|
||||
if not self.client == None:
|
||||
self.client.isconnected = False
|
||||
self.client.authenticated = False
|
||||
self.client.channels = []
|
||||
error = reason.getErrorMessage()
|
||||
log("%s - %i: connection lost: %s" % (self.net, self.num, error))
|
||||
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))
|
||||
sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "lost", "message": error})
|
||||
self.retry(connector)
|
||||
@@ -681,6 +691,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
||||
def clientConnectionFailed(self, connector, reason):
|
||||
if not self.client == 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))
|
||||
|
||||
Reference in New Issue
Block a user