Use net and num instead of name in relay output

pull/1/head
Mark Veidemanis 5 years ago
parent 78e4d6bd66
commit 5eda50af13

@ -145,7 +145,7 @@ class IRCBot(IRCClient):
if "msg" in cast.keys(): if "msg" in cast.keys():
if cast["ident"] == "znc" and cast["host"] == "znc.in": if cast["ident"] == "znc" and cast["host"] == "znc.in":
cast["type"] = "znc" cast["type"] = "znc"
cast["name"] = self.name cast["num"] = self.num
del cast["nick"] del cast["nick"]
del cast["ident"] del cast["ident"]
del cast["host"] del cast["host"]
@ -156,7 +156,7 @@ class IRCBot(IRCClient):
#castDup = deepcopy(cast) # however modes are not queries! #castDup = deepcopy(cast) # however modes are not queries!
cast["mtype"] = cast["type"] cast["mtype"] = cast["type"]
cast["type"] = "query" cast["type"] = "query"
cast["name"] = self.name cast["num"] = self.num
#self.event(**castDup) #self.event(**castDup)
# Don't call self.event for this one because queries are not events on a # Don't call self.event for this one because queries are not events on a
# channel, but we still want to see them # channel, but we still want to see them
@ -165,14 +165,14 @@ class IRCBot(IRCClient):
castDup = deepcopy(cast) castDup = deepcopy(cast)
castDup["mtype"] = cast["type"] castDup["mtype"] = cast["type"]
castDup["type"] = "self" castDup["type"] = "self"
castDup["name"] = self.name cast["num"] = self.num
self.event(**castDup) self.event(**castDup)
if "nick" in cast.keys(): if "nick" in cast.keys():
if cast["nick"].lower() == self.nickname.lower(): if cast["nick"].lower() == self.nickname.lower():
castDup = deepcopy(cast) castDup = deepcopy(cast)
castDup["mtype"] = cast["type"] castDup["mtype"] = cast["type"]
castDup["type"] = "self" castDup["type"] = "self"
castDup["name"] = self.name cast["num"] = self.num
if not cast["channel"].lower() == self.nickname.lower(): # modes has been set on us directly if not cast["channel"].lower() == self.nickname.lower(): # modes has been set on us directly
self.event(**castDup) # don't tell anyone else self.event(**castDup) # don't tell anyone else
if "msg" in cast.keys() and not cast["type"] == "query": # Don't highlight queries if "msg" in cast.keys() and not cast["type"] == "query": # Don't highlight queries
@ -181,13 +181,13 @@ class IRCBot(IRCClient):
castDup = deepcopy(cast) castDup = deepcopy(cast)
castDup["mtype"] = cast["type"] castDup["mtype"] = cast["type"]
castDup["type"] = "highlight" castDup["type"] = "highlight"
castDup["name"] = self.name cast["num"] = self.num
self.event(**castDup) self.event(**castDup)
if not "name" in cast.keys(): if not "net" in cast.keys():
cast["name"] = self.net cast["net"] = self.net
counters.event(self.net, cast["type"]) counters.event(self.net, cast["type"])
monitor.event(self.name, cast) monitor.event(self.net, cast)
def privmsg(self, user, channel, msg): def privmsg(self, user, channel, msg):
self.event(type="msg", muser=user, channel=channel, msg=msg) self.event(type="msg", muser=user, channel=channel, msg=msg)
@ -225,8 +225,8 @@ class IRCBot(IRCClient):
def irc_ERR_PASSWDMISMATCH(self, prefix, params): def irc_ERR_PASSWDMISMATCH(self, prefix, params):
print(locals()) print(locals())
print(globals()) print(globals())
log("%s: password mismatch" % self.name) log("%s - %i: password mismatch" % (self.net, self.num))
sendAll("%s: password mismatch" % self.name) sendAll("%s - %i: password mismatch" % (self.net, self.num))
def _who(self, channel): def _who(self, channel):
d = Deferred() d = Deferred()
@ -378,9 +378,9 @@ class IRCBot(IRCClient):
def signedOn(self): def signedOn(self):
self.connected = True self.connected = True
log("signed on: %s" % self.name) log("signed on: %s - %i" % (self.net, self.num))
#self.event(type="conn", status="connected") #self.event(type="conn", status="connected")
sendRelayNotification({"type": "conn", "name": self.name, "status": "signedon"}) sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "signedon"})
def joined(self, channel): def joined(self, channel):
if not channel in self.channels: if not channel in self.channels:
@ -426,7 +426,9 @@ class IRCBot(IRCClient):
def chanlessEvent(self, cast): def chanlessEvent(self, cast):
cast["nick"], cast["ident"], cast["host"] = self.parsen(cast["muser"]) cast["nick"], cast["ident"], cast["host"] = self.parsen(cast["muser"])
if dedup(self.name, cast): if dedup(self.name, cast): # Needs to be kept self.name until the dedup
# function is converted to the new net, num
# format
return # stop right there sir! return # stop right there sir!
chans = userinfo.getChanList(self.net, cast["nick"]) chans = userinfo.getChanList(self.net, cast["nick"])
if chans == None: if chans == None:
@ -456,10 +458,10 @@ class IRCBotFactory(ReconnectingClientFactory):
def __init__(self, net, num=None, relayCommands=None, user=None, stage2=None): def __init__(self, net, num=None, relayCommands=None, user=None, stage2=None):
if net == None: if net == None:
self.num = num self.num = num
self.name = "Relay to %i" % num self.name = "relay - %i" % num
self.relay = True self.relay = True
else: else:
self.name = net + str(num) self.name = net+str(num)
self.num = num self.num = num
self.net = net self.net = net
self.relay = False self.relay = False
@ -488,10 +490,10 @@ class IRCBotFactory(ReconnectingClientFactory):
self.client.connected = False self.client.connected = False
self.client.channels = [] self.client.channels = []
error = reason.getErrorMessage() error = reason.getErrorMessage()
log("%s: connection lost: %s" % (self.name, error)) log("%s - %i: connection lost: %s" % (self.net, self.num, error))
if not self.relay: if not self.relay:
sendAll("%s: connection lost: %s" % (self.name, error)) sendAll("%s - %i: connection lost: %s" % (self.net, self.num, error))
sendRelayNotification({"type": "conn", "name": self.name, "status": "lost", "message": error}) sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "lost", "message": error})
self.retry(connector) self.retry(connector)
#ReconnectingClientFactory.clientConnectionLost(self, connector, reason) #ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
@ -500,10 +502,10 @@ class IRCBotFactory(ReconnectingClientFactory):
self.client.connected = False self.client.connected = False
self.client.channels = [] self.client.channels = []
error = reason.getErrorMessage() error = reason.getErrorMessage()
log("%s: connection failed: %s" % (self.name, error)) log("%s - %i: connection failed: %s" % (self.net, self.num, error))
if not self.relay: if not self.relay:
sendAll("%s: connection failed: %s" % (self.name, error)) sendAll("%s -%s: connection failed: %s" % (self.net, self.num, error))
sendRelayNotification({"type": "conn", "name": self.name, "status": "failed", "message": error}) sendRelayNotification({"type": "conn", "net": self.net, "num": self.num, "status": "failed", "message": error})
self.retry(connector) self.retry(connector)
#ReconnectingClientFactory.clientConnectionFailed(self, connector, reason) #ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)

Loading…
Cancel
Save