Improvements to query and self event detection, implement all command and debug flags
This commit is contained in:
35
core/bot.py
35
core/bot.py
@@ -9,10 +9,11 @@ from random import randint
|
||||
from copy import deepcopy
|
||||
|
||||
from modules import userinfo
|
||||
from modules import counters as count
|
||||
from modules import counters
|
||||
from modules import monitor
|
||||
|
||||
from core.relay import sendRelayNotification
|
||||
from utils.dedup import dedup
|
||||
|
||||
import main
|
||||
from utils.logging.log import *
|
||||
@@ -151,9 +152,9 @@ class IRCBot(IRCClient):
|
||||
del cast["host"]
|
||||
del cast["target"]
|
||||
if not cast["type"] in ["query", "self", "highlight", "znc", "who"]:
|
||||
if "target" in cast.keys():
|
||||
if cast["target"].lower() == self.nickname.lower():
|
||||
#castDup = deepcopy(cast)
|
||||
if "target" in cast.keys() and not cast["type"] == "mode": # don't handle modes here
|
||||
if cast["target"].lower() == self.nickname.lower(): # as they are target == nickname
|
||||
#castDup = deepcopy(cast) # however modes are not queries!
|
||||
cast["mtype"] = cast["type"]
|
||||
cast["type"] = "query"
|
||||
cast["name"] = self.name
|
||||
@@ -173,7 +174,8 @@ class IRCBot(IRCClient):
|
||||
castDup["mtype"] = cast["type"]
|
||||
castDup["type"] = "self"
|
||||
castDup["name"] = self.name
|
||||
self.event(**castDup)
|
||||
if not cast["target"].lower() == self.nickname.lower(): # modes has been set on us directly
|
||||
self.event(**castDup) # don't tell anyone else
|
||||
if "message" in cast.keys() and not cast["type"] == "query": # Don't highlight queries
|
||||
if self.nickname.lower() in cast["message"].lower():
|
||||
castDup = deepcopy(cast)
|
||||
@@ -184,8 +186,8 @@ class IRCBot(IRCClient):
|
||||
|
||||
if not "name" in cast.keys():
|
||||
cast["name"] = self.net
|
||||
count.event(self.net, cast["type"])
|
||||
monitor.event(cast)
|
||||
counters.event(self.net, cast["type"])
|
||||
monitor.event(self.name, cast)
|
||||
|
||||
def privmsg(self, user, channel, msg):
|
||||
self.event(type="msg", muser=user, target=channel, message=msg)
|
||||
@@ -408,37 +410,40 @@ class IRCBot(IRCClient):
|
||||
self.event(type="part", muser=user, target=channel, message=message)
|
||||
|
||||
def userQuit(self, user, quitMessage):
|
||||
self.chanlessEvent(type="quit", muser=user, message=quitMessage)
|
||||
self.chanlessEvent({"type": "quit", "muser": user, "message": quitMessage})
|
||||
|
||||
def userKicked(self, kickee, channel, kicker, message):
|
||||
if kickee.lower() == self.nickname.lower():
|
||||
self.botLeft(channel)
|
||||
self.event(type="kick", muser=kicker, target=channel, message=message, user=kickee)
|
||||
|
||||
def chanlessEvent(self, **cast):
|
||||
chans = userinfo.getChansSingle(self.net, cast["nick"])
|
||||
def chanlessEvent(self, cast):
|
||||
cast["nick"], cast["ident"], cast["host"] = self.parsen(cast["muser"])
|
||||
if dedup(self.name, cast):
|
||||
return # stop right there sir!
|
||||
chans = userinfo.getChanList(self.net, cast["nick"])
|
||||
if chans == None:
|
||||
self.event(**cast)
|
||||
error("No channels returned for chanless event: %s" % cast)
|
||||
# self.event(**cast) -- no, should NEVER happen
|
||||
return
|
||||
# getChansSingle returns all channels of the user, we only want to use
|
||||
# ones we have common with them
|
||||
realChans = set(chans).intersection(set(self.channels))
|
||||
for i in chans:
|
||||
for i in realChans:
|
||||
cast["target"] = i
|
||||
self.event(**cast)
|
||||
|
||||
def userRenamed(self, oldname, newname):
|
||||
self.chanlessEvent(type="nick", muser=oldname, user=newname)
|
||||
self.chanlessEvent({"type": "nick", "muser": oldname, "user": newname})
|
||||
|
||||
def topicUpdated(self, user, channel, newTopic):
|
||||
self.event(type="topic", muser=user, target=channel, message= newTopic)
|
||||
|
||||
def modeChanged(self, user, channel, toset, modes, args):
|
||||
nick, ident, host = self.parsen(user)
|
||||
argList = list(args)
|
||||
modeList = [i for i in modes]
|
||||
for a, m in zip(argList, modeList):
|
||||
self.event(type="mode", nick=nick, ident=ident, host=host, target=channel, modes=m, status=toset, modeargs=a)
|
||||
self.event(type="mode", muser=user, target=channel, modes=m, status=toset, modeargs=a)
|
||||
|
||||
class IRCBotFactory(ReconnectingClientFactory):
|
||||
def __init__(self, name, relay=None, relayCommands=None, user=None, stage2=None):
|
||||
|
||||
Reference in New Issue
Block a user