Make monitor notifications ignore numbers to support multiple networks in only one reference
This commit is contained in:
parent
de5baf562b
commit
b31b5d40e8
53
core/bot.py
53
core/bot.py
|
@ -2,7 +2,7 @@ from twisted.internet.protocol import ReconnectingClientFactory
|
||||||
from twisted.words.protocols.irc import IRCClient
|
from twisted.words.protocols.irc import IRCClient
|
||||||
from twisted.internet.defer import Deferred
|
from twisted.internet.defer import Deferred
|
||||||
from twisted.internet.task import LoopingCall
|
from twisted.internet.task import LoopingCall
|
||||||
|
from string import digits
|
||||||
from random import randint
|
from random import randint
|
||||||
|
|
||||||
import modules.keyword as keyword
|
import modules.keyword as keyword
|
||||||
|
@ -18,6 +18,7 @@ class IRCBot(IRCClient):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
self.connected = False
|
self.connected = False
|
||||||
self.channels = []
|
self.channels = []
|
||||||
|
self.net = "".join([x for x in name if not x in digits])
|
||||||
self.buffer = ""
|
self.buffer = ""
|
||||||
self.name = name
|
self.name = name
|
||||||
instance = main.pool[name]
|
instance = main.pool[name]
|
||||||
|
@ -70,27 +71,27 @@ class IRCBot(IRCClient):
|
||||||
|
|
||||||
def privmsg(self, user, channel, msg):
|
def privmsg(self, user, channel, msg):
|
||||||
nick, ident, host = self.parsen(user)
|
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")
|
count.event(self.name, "privmsg")
|
||||||
|
|
||||||
keyword.actKeyword(user, channel, msg, self.nickname, "MSG", self.name)
|
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):
|
def noticed(self, user, channel, msg):
|
||||||
nick, ident, host = self.parsen(user)
|
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")
|
count.event(self.name, "notice")
|
||||||
|
|
||||||
keyword.actKeyword(user, channel, msg, self.nickname, "NOTICE", self.name)
|
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):
|
def action(self, user, channel, msg):
|
||||||
nick, ident, host = self.parsen(user)
|
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")
|
count.event(self.name, "action")
|
||||||
|
|
||||||
keyword.actKeyword(user, channel, msg, self.nickname, "ACTION", self.name)
|
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):
|
def get(self, var):
|
||||||
try:
|
try:
|
||||||
|
@ -142,7 +143,7 @@ class IRCBot(IRCClient):
|
||||||
n = self._who[channel][1]
|
n = self._who[channel][1]
|
||||||
n[nick] = [nick, user, host, server, status, realname]
|
n[nick] = [nick, user, host, server, status, realname]
|
||||||
count.event(self.name, "whoreply")
|
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):
|
def irc_RPL_ENDOFWHO(self, prefix, params):
|
||||||
channel = params[1]
|
channel = params[1]
|
||||||
|
@ -259,73 +260,73 @@ class IRCBot(IRCClient):
|
||||||
self.channels.remove(channel)
|
self.channels.remove(channel)
|
||||||
keyword.actKeyword(self.nickname, channel, message, self.nickname, "SELFPART", self.name)
|
keyword.actKeyword(self.nickname, channel, message, self.nickname, "SELFPART", self.name)
|
||||||
count.event(self.name, "selfpart")
|
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 = self._getWho[channel]
|
||||||
lc.stop()
|
lc.stop()
|
||||||
|
|
||||||
def kickedFrom(self, channel, kicker, message):
|
def kickedFrom(self, channel, kicker, message):
|
||||||
nick, ident, host = self.parsen(kicker)
|
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:
|
if channel in self.channels:
|
||||||
self.channels.remove(channel)
|
self.channels.remove(channel)
|
||||||
keyword.sendMaster("KICK %s: (%s/%s) %s" % (self.name, kicker, channel, message))
|
keyword.sendMaster("KICK %s: (%s/%s) %s" % (self.name, kicker, channel, message))
|
||||||
count.event(self.name, "selfkick")
|
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 = self._getWho[channel]
|
||||||
lc.stop()
|
lc.stop()
|
||||||
|
|
||||||
def userJoined(self, user, channel):
|
def userJoined(self, user, channel):
|
||||||
nick, ident, host = self.parsen(user)
|
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")
|
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):
|
def userLeft(self, user, channel, message):
|
||||||
nick, ident, host = self.parsen(user)
|
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)
|
keyword.actKeyword(user, channel, message, self.nickname, "PART", self.name)
|
||||||
count.event(self.name, "part")
|
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):
|
def userQuit(self, user, quitMessage):
|
||||||
nick, ident, host = self.parsen(user)
|
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")
|
count.event(self.name, "quit")
|
||||||
|
|
||||||
keyword.actKeyword(user, None, quitMessage, self.nickname, "QUIT", self.name)
|
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):
|
def userKicked(self, kickee, channel, kicker, message):
|
||||||
nick, ident, host = self.parsen(kicker)
|
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")
|
count.event(self.name, "kick")
|
||||||
|
|
||||||
keyword.actKeyword(kicker, channel, message, self.nickname, "KICK", self.name)
|
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):
|
def userRenamed(self, oldname, newname):
|
||||||
nick, ident, host = self.parsen(oldname)
|
nick, ident, host = self.parsen(oldname)
|
||||||
userinfo.setWhoSingle(self.name, nick, ident, host)
|
userinfo.setWhoSingle(self.net, nick, ident, host)
|
||||||
userinfo.setWhoSingle(self.name, newname, ident, host)
|
userinfo.setWhoSingle(self.net, newname, ident, host)
|
||||||
count.event(self.name, "nick")
|
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):
|
def topicUpdated(self, user, channel, newTopic):
|
||||||
nick, ident, host = self.parsen(user)
|
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")
|
count.event(self.name, "topic")
|
||||||
|
|
||||||
keyword.actKeyword(user, channel, newTopic, self.nickname, "TOPIC", self.name)
|
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):
|
def modeChanged(self, user, channel, toset, modes, args):
|
||||||
nick, ident, host = self.parsen(user)
|
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")
|
count.event(self.name, "mode")
|
||||||
argList = list(args)
|
argList = list(args)
|
||||||
modeList = [i for i in modes]
|
modeList = [i for i in modes]
|
||||||
for a, m in zip(argList, modeList):
|
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):
|
class IRCBotFactory(ReconnectingClientFactory):
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
|
|
|
@ -3,7 +3,6 @@ from string import digits
|
||||||
#from utils.logging.log import *
|
#from utils.logging.log import *
|
||||||
|
|
||||||
def setWho(network, newObjects):
|
def setWho(network, newObjects):
|
||||||
network = "".join([x for x in network if not x in digits])
|
|
||||||
if not network in main.wholist.keys():
|
if not network in main.wholist.keys():
|
||||||
main.wholist[network] = {}
|
main.wholist[network] = {}
|
||||||
for i in newObjects.keys():
|
for i in newObjects.keys():
|
||||||
|
@ -12,8 +11,6 @@ def setWho(network, newObjects):
|
||||||
return
|
return
|
||||||
|
|
||||||
def setWhoSingle(network, nick, ident, host):
|
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 network in main.wholist.keys():
|
||||||
if nick in main.wholist[network].keys():
|
if nick in main.wholist[network].keys():
|
||||||
main.wholist[network][nick][1] = ident
|
main.wholist[network][nick][1] = ident
|
||||||
|
|
Loading…
Reference in New Issue