Make monitor notifications ignore numbers to support multiple networks in only one reference

pull/1/head
Mark Veidemanis 6 years ago
parent de5baf562b
commit b31b5d40e8

@ -2,7 +2,7 @@ from twisted.internet.protocol import ReconnectingClientFactory
from twisted.words.protocols.irc import IRCClient
from twisted.internet.defer import Deferred
from twisted.internet.task import LoopingCall
from string import digits
from random import randint
import modules.keyword as keyword
@ -18,6 +18,7 @@ class IRCBot(IRCClient):
def __init__(self, name):
self.connected = False
self.channels = []
self.net = "".join([x for x in name if not x in digits])
self.buffer = ""
self.name = name
instance = main.pool[name]
@ -70,27 +71,27 @@ class IRCBot(IRCClient):
def privmsg(self, user, channel, msg):
nick, ident, host = self.parsen(user)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
count.event(self.name, "privmsg")
keyword.actKeyword(user, channel, msg, self.nickname, "MSG", self.name)
monitor.event(self.name, channel, {"type": "msg", "exact": user, "nick": nick, "ident": ident, "host": host, "message": msg})
monitor.event(self.net, channel, {"type": "msg", "exact": user, "nick": nick, "ident": ident, "host": host, "message": msg})
def noticed(self, user, channel, msg):
nick, ident, host = self.parsen(user)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
count.event(self.name, "notice")
keyword.actKeyword(user, channel, msg, self.nickname, "NOTICE", self.name)
monitor.event(self.name, channel, {"type": "notice", "exact": user, "nick": nick, "ident": ident, "host": host, "message": msg})
monitor.event(self.net, channel, {"type": "notice", "exact": user, "nick": nick, "ident": ident, "host": host, "message": msg})
def action(self, user, channel, msg):
nick, ident, host = self.parsen(user)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
count.event(self.name, "action")
keyword.actKeyword(user, channel, msg, self.nickname, "ACTION", self.name)
monitor.event(self.name, channel, {"type": "action", "exact": user, "nick": nick, "ident": ident, "host": host, "message": msg})
monitor.event(self.net, channel, {"type": "action", "exact": user, "nick": nick, "ident": ident, "host": host, "message": msg})
def get(self, var):
try:
@ -142,7 +143,7 @@ class IRCBot(IRCClient):
n = self._who[channel][1]
n[nick] = [nick, user, host, server, status, realname]
count.event(self.name, "whoreply")
monitor.event(self.name, channel, {"type": "who", "exact": nick+"!"+user+"@"+host, "nick": nick, "ident": user, "host": host, "realname": realname, "server": server, "status": status})
monitor.event(self.net, channel, {"type": "who", "exact": nick+"!"+user+"@"+host, "nick": nick, "ident": user, "host": host, "realname": realname, "server": server, "status": status})
def irc_RPL_ENDOFWHO(self, prefix, params):
channel = params[1]
@ -259,73 +260,73 @@ class IRCBot(IRCClient):
self.channels.remove(channel)
keyword.actKeyword(self.nickname, channel, message, self.nickname, "SELFPART", self.name)
count.event(self.name, "selfpart")
monitor.event(self.name, channel, {"type": "part", "message": message})
monitor.event(self.net, channel, {"type": "part", "message": message})
lc = self._getWho[channel]
lc.stop()
def kickedFrom(self, channel, kicker, message):
nick, ident, host = self.parsen(kicker)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
if channel in self.channels:
self.channels.remove(channel)
keyword.sendMaster("KICK %s: (%s/%s) %s" % (self.name, kicker, channel, message))
count.event(self.name, "selfkick")
monitor.event(self.name, channel, {"type": "kick", "exact": kicker, "nick": nick, "ident": ident, "host": host, "message": message})
monitor.event(self.net, channel, {"type": "kick", "exact": kicker, "nick": nick, "ident": ident, "host": host, "message": message})
lc = self._getWho[channel]
lc.stop()
def userJoined(self, user, channel):
nick, ident, host = self.parsen(user)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
count.event(self.name, "join")
monitor.event(self.name, channel, {"type": "join", "exact": user, "nick": nick, "ident": ident, "host": host})
monitor.event(self.net, channel, {"type": "join", "exact": user, "nick": nick, "ident": ident, "host": host})
def userLeft(self, user, channel, message):
nick, ident, host = self.parsen(user)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
keyword.actKeyword(user, channel, message, self.nickname, "PART", self.name)
count.event(self.name, "part")
monitor.event(self.name, channel, {"type": "part", "exact": user, "nick": nick, "ident": ident, "host": host, "message": message})
monitor.event(self.net, channel, {"type": "part", "exact": user, "nick": nick, "ident": ident, "host": host, "message": message})
def userQuit(self, user, quitMessage):
nick, ident, host = self.parsen(user)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
count.event(self.name, "quit")
keyword.actKeyword(user, None, quitMessage, self.nickname, "QUIT", self.name)
monitor.event(self.name, None, {"type": "quit", "exact": user, "nick": nick, "ident": ident, "host": host, "message": quitMessage})
monitor.event(self.net, None, {"type": "quit", "exact": user, "nick": nick, "ident": ident, "host": host, "message": quitMessage})
def userKicked(self, kickee, channel, kicker, message):
nick, ident, host = self.parsen(kicker)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
count.event(self.name, "kick")
keyword.actKeyword(kicker, channel, message, self.nickname, "KICK", self.name)
monitor.event(self.name, channel, {"type": "kick", "exact": kicker, "nick": nick, "ident": ident, "host": host, "message": message, "user": kickee})
monitor.event(self.net, channel, {"type": "kick", "exact": kicker, "nick": nick, "ident": ident, "host": host, "message": message, "user": kickee})
def userRenamed(self, oldname, newname):
nick, ident, host = self.parsen(oldname)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.name, newname, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
userinfo.setWhoSingle(self.net, newname, ident, host)
count.event(self.name, "nick")
monitor.event(self.name, None, {"type": "nick", "exact": oldname, "nick": nick, "ident": ident, "host": host, "user": newname})
monitor.event(self.net, None, {"type": "nick", "exact": oldname, "nick": nick, "ident": ident, "host": host, "user": newname})
def topicUpdated(self, user, channel, newTopic):
nick, ident, host = self.parsen(user)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
count.event(self.name, "topic")
keyword.actKeyword(user, channel, newTopic, self.nickname, "TOPIC", self.name)
monitor.event(self.name, channel, {"type": "topic", "exact": user, "nick": nick, "ident": ident, "host": host, "message": newTopic})
monitor.event(self.net, channel, {"type": "topic", "exact": user, "nick": nick, "ident": ident, "host": host, "message": newTopic})
def modeChanged(self, user, channel, toset, modes, args):
nick, ident, host = self.parsen(user)
userinfo.setWhoSingle(self.name, nick, ident, host)
userinfo.setWhoSingle(self.net, nick, ident, host)
count.event(self.name, "mode")
argList = list(args)
modeList = [i for i in modes]
for a, m in zip(argList, modeList):
monitor.event(self.name, channel, {"type": "mode", "exact": user, "nick": nick, "ident": ident, "host": host, "modes": m, "modeargs": a})
monitor.event(self.net, channel, {"type": "mode", "exact": user, "nick": nick, "ident": ident, "host": host, "modes": m, "modeargs": a})
class IRCBotFactory(ReconnectingClientFactory):
def __init__(self, name):

@ -3,7 +3,6 @@ from string import digits
#from utils.logging.log import *
def setWho(network, newObjects):
network = "".join([x for x in network if not x in digits])
if not network in main.wholist.keys():
main.wholist[network] = {}
for i in newObjects.keys():
@ -12,8 +11,6 @@ def setWho(network, newObjects):
return
def setWhoSingle(network, nick, ident, host):
network = "".join([x for x in network if not x in digits])
if network in main.wholist.keys():
if nick in main.wholist[network].keys():
main.wholist[network][nick][1] = ident

Loading…
Cancel
Save