Implement counting keyword events and a unified buffers system for when the master channel is unavailable

This commit is contained in:
2018-03-04 17:25:57 +00:00
parent eae4315562
commit da6c45f093
16 changed files with 60 additions and 19 deletions

View File

@@ -1,11 +1,36 @@
from core.main import *
from utils.logging.log import *
import modules.counters as count
def sendMaster(data):
if config["Master"][0] in IRCPool.keys():
IRCPool[config["Master"][0]].msg(config["Master"][1], data)
if not len(MonitorPool) == 0:
hasMonitors = True
else:
hasMonitors = False
if config["Master"] == [None, None]:
if hasMonitors:
for i in MonitorPool:
connections[i].send(data)
return
else:
masterbuf.append(data)
saveConf("masterbuf")
return
if config["Master"][0] in IRCPool.keys():
if config["Master"][1] in IRCPool[config["Master"][0]].channels:
IRCPool[config["Master"][0]].msg(config["Master"][1], data)
else:
if not hasMonitors:
masterbuf.append(data)
saveConf("masterbuf")
else:
if not hasMonitors:
masterbuf.append(data)
saveConf("masterbuf")
warn("Master with no IRC instance defined")
for i in MonitorPool:
connections[i].send(data)
@@ -52,8 +77,10 @@ def actKeyword(user, channel, message, nickname, actType, name):
if nickLower in msgLower:
msgLower = msgLower.replace(nickLower, "{"+nickLower+"}")
sendMaster("NICK %s %s (T:%s): (%s/%s) %s" % (actType, name, msgLower.count(nickLower), user, channel, msgLower))
count.event(name, "nickhighlight")
if toSend:
sendMaster("MATCH %s %s (U:%s T:%s): (%s/%s) %s" % (actType, name, toSend[1], toSend[2], user, channel, toSend[0]))
count.event(name, "keymatch")
def addKeyword(keyword):
if keyword in keyconf["Keywords"]:

View File

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