Implement query notifications and recognise ZNC's messages
This commit is contained in:
parent
2e2e35cad7
commit
66e7785f6f
|
@ -13,6 +13,9 @@ class Add:
|
|||
|
||||
if length > 1:
|
||||
name = spl[1]
|
||||
if name.isdigit():
|
||||
failure("Network name is all numbers. This will break things.")
|
||||
return
|
||||
else:
|
||||
incUsage("add")
|
||||
return
|
||||
|
@ -71,9 +74,7 @@ class Add:
|
|||
failure("Protocol must be ssl or plain, not %s" % protocol)
|
||||
return
|
||||
|
||||
try:
|
||||
int(port)
|
||||
except:
|
||||
if not port.isdigit():
|
||||
failure("Port must be an integer, not %s" % port)
|
||||
return
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class Delete:
|
|||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
del pool[spl[1]]
|
||||
del main.pool[spl[1]]
|
||||
if spl[1] in main.ReactorPool.keys():
|
||||
if spl[1] in main.FactoryPool.keys():
|
||||
main.FactoryPool[spl[1]].stopTrying()
|
||||
|
|
|
@ -48,7 +48,7 @@ class Key:
|
|||
return
|
||||
else:
|
||||
if not spl[2] in spl[3]:
|
||||
failure("Keyword %s not in exception %s. This won't work" % (spl[2], spl[3]))
|
||||
failure("Keyword %s not in exception %s. This won't work." % (spl[2], spl[3]))
|
||||
return
|
||||
main.keyconf["KeywordsExcept"][spl[2]] = []
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import main
|
||||
|
||||
class Msg:
|
||||
def __init__(self, register):
|
||||
register("msg", self.msg)
|
||||
|
||||
def msg(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
if authed:
|
||||
if length >= 4:
|
||||
if not spl[1] in main.pool.keys():
|
||||
failure("Name does not exist: %s" % spl[1])
|
||||
return
|
||||
if not spl[1] in main.IRCPool.keys():
|
||||
failure("Name has no instance: %s" % spl[1])
|
||||
return
|
||||
if not spl[2] in main.IRCPool[spl[1]].channels:
|
||||
info("Bot not on channel: %s" % spl[2])
|
||||
main.IRCPool[spl[1]].msg(spl[2], " ".join(spl[3:]))
|
||||
success("Sent %s to %s on %s" % (" ".join(spl[3:]), spl[2], spl[1]))
|
||||
return
|
||||
else:
|
||||
incUsage("msg")
|
||||
return
|
||||
else:
|
||||
incUsage(None)
|
|
@ -8,14 +8,25 @@
|
|||
},
|
||||
"UsePassword": true,
|
||||
"ConnectOnCreate": false,
|
||||
"HighlightNotifications": true,
|
||||
"ConnectionNotifications": true,
|
||||
"Notifications": {
|
||||
"Highlight": true,
|
||||
"Connection": true,
|
||||
"Query": true
|
||||
},
|
||||
"Compat": {
|
||||
"ZNC": true
|
||||
},
|
||||
"Dist": {
|
||||
"Enabled": true,
|
||||
"SendOutput": false,
|
||||
"File": "conf/dist.sh"
|
||||
},
|
||||
"Password": "s",
|
||||
"Tweaks": {
|
||||
"ZNC": {
|
||||
"Prefix": "*"
|
||||
}
|
||||
},
|
||||
"Default": {
|
||||
"host": null,
|
||||
"port": null,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
"mod": "mod <name> [<key>] [<value>]",
|
||||
"default": "default [<key>] [<value>]",
|
||||
"get": "get <name> <variable>",
|
||||
"key": "key <master|show|add|del|except|unexcept|showexcept|monitor> [<name>] [<target>] [<key>] [<on|off>]",
|
||||
"key": "key <master|show|add|del|except|unexcept|showexcept|monitor> [<name>] [<target>] [<key...>] [<on|off>]",
|
||||
"who": "who <nick>",
|
||||
"join": "join <name> <channel> [<key>]",
|
||||
"enable": "enable <name>",
|
||||
|
@ -16,5 +16,6 @@
|
|||
"save": "save <config|keyconf|pool|help|wholist|counters|masterbuf|all>",
|
||||
"load": "load <config|keyconf|pool|help|wholist|counters|masterbuf|all>",
|
||||
"dist": "dist",
|
||||
"loadmod": "loadmod <module>"
|
||||
}
|
||||
"loadmod": "loadmod <module>",
|
||||
"msg": "msg <name> <target> <message...>"
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ class IRCBot(IRCClient):
|
|||
def signedOn(self):
|
||||
self.connected = True
|
||||
log("signed on: %s" % self.name)
|
||||
if main.config["ConnectionNotifications"]:
|
||||
if main.config["Notifications"]["Connection"]:
|
||||
keyword.sendMaster("SIGNON: %s" % self.name)
|
||||
if self.authtype == "ns":
|
||||
self.msg(self.authentity, "IDENTIFY %s" % self.nspass)
|
||||
|
@ -316,7 +316,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
|||
error = reason.getErrorMessage()
|
||||
log("%s: connection lost: %s" % (self.name, error))
|
||||
sendAll("%s: connection lost: %s" % (self.name, error))
|
||||
if main.config["ConnectionNotifications"]:
|
||||
if main.config["Notifications"]["Connection"]:
|
||||
keyword.sendMaster("CONNLOST %s: %s" % (self.name, error))
|
||||
self.retry(connector)
|
||||
#ReconnectingClientFactory.clientConnectionLost(self, connector, reason)
|
||||
|
@ -328,7 +328,7 @@ class IRCBotFactory(ReconnectingClientFactory):
|
|||
error = reason.getErrorMessage()
|
||||
log("%s: connection failed: %s" % (self.name, error))
|
||||
sendAll("%s: connection failed: %s" % (self.name, error))
|
||||
if main.config["ConnectionNotifications"]:
|
||||
if main.config["Notifications"]["Connection"]:
|
||||
keyword.sendMaster("CONNFAIL %s: %s" % (self.name, error))
|
||||
self.retry(connector)
|
||||
#ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue