Implement query notifications and recognise ZNC's messages

This commit is contained in:
2018-05-07 19:58:19 +01:00
parent 2e2e35cad7
commit 66e7785f6f
8 changed files with 74 additions and 19 deletions

View File

@@ -75,13 +75,30 @@ def actKeyword(user, channel, message, nickname, actType, name):
if name == main.config["Master"][0] and channel == main.config["Master"][1]:
pass
else:
if main.config["HighlightNotifications"]:
msgLower = message.lower()
nickLower = nickname.lower()
if nickLower in msgLower:
msgLower = msgLower.replace(nickLower, "{"+nickLower+"}")
msgLower = message.lower()
nickLower = nickname.lower()
if nickLower in msgLower: # Someone has said the bot's nickname
msgLower = msgLower.replace(nickLower, "{"+nickLower+"}")
count.event(name, "nickhighlight")
if main.config["Notifications"]["Highlight"]:
sendMaster("NICK %s %s (T:%s): (%s/%s) %s" % (actType, name, msgLower.count(nickLower), user, channel, msgLower))
count.event(name, "nickhighlight")
if not channel == None:
chanLower = channel.lower()
if nickLower == chanLower: # I received a message directed only at me
ZNCAlreadySent = False
if main.config["Notifications"]["Query"]:
if user == main.config["Tweaks"]["ZNC"]["Prefix"] + "status!znc@znc.in":
if main.config["Compat"]["ZNC"]:
sendMaster("ZNC %s %s: (%s/%s) %s" % (actType, name, user, channel, msgLower))
ZNCAlreadySent = True
else:
sendMaster("QUERY %s %s: (%s) %s" % (actType, name, user, msgLower))
else:
sendMaster("QUERY %s %s: (%s) %s" % (actType, name, user, msgLower))
if not ZNCAlreadySent == True:
if main.config["Compat"]["ZNC"]:
if user == main.config["Tweaks"]["ZNC"]["Prefix"] + "status!znc@znc.in":
sendMaster("ZNC %s %s: (%s/%s) %s" % (actType, name, user, channel, msgLower))
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")