Implement notifications when the bot's nickname is said

This commit is contained in:
Mark Veidemanis 2017-11-30 18:54:08 +00:00
parent e6367af7f2
commit cc75535bcf
2 changed files with 28 additions and 12 deletions

View File

@ -6,6 +6,7 @@
"ListenerCertificate": "cert.pem",
"UsePassword": true,
"ConnectOnCreate": false,
"HighlightNotifications": true,
"Password": "s",
"Default": {
"password": null,

View File

@ -83,26 +83,41 @@ class IRCBot(IRCClient):
def privmsg(self, user, channel, msg):
toSend = helper.isKeyword(msg)
if toSend:
if self.name == config["Master"][0] and channel == config["Master"][1]:
pass
else:
if config["HighlightNotifications"]:
msgLower = msg.lower()
if self.nickname.lower() in msgLower:
msgLower = msgLower.replace(self.nickname, "{"+self.nickname+"}")
helper.sendMaster("NICK PRV %s (T:%s): (%s/%s) %s" % (self.name, msg.count(self.nickname), user, channel, msgLower))
if toSend:
helper.sendMaster("MATCH PRV %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0]))
def noticed(self, user, channel, msg):
toSend = helper.isKeyword(msg)
if toSend:
if self.name == config["Master"][0] and channel == config["Master"][1]:
pass
else:
if config["HighlightNotifications"]:
msgLower = msg.lower()
if self.nickname.lower() in msgLower:
msgLower = msgLower.replace(self.nickname, "{"+self.nickname+"}")
helper.sendMaster("NICK NOT %s (T:%s): (%s/%s) %s" % (self.name, msg.count(self.nickname), user, channel, msgLower))
if toSend:
helper.sendMaster("MATCH NOT %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0]))
def action(self, user, channel, msg):
toSend = helper.isKeyword(msg)
if toSend:
if self.name == config["Master"][0] and channel == config["Master"][1]:
pass
else:
if config["HighlightNotifications"]:
msgLower = msg.lower()
if self.nickname.lower() in msgLower:
msgLower = msgLower.replace(self.nickname, "{"+self.nickname+"}")
helper.sendMaster("NICK ACT %s (T:%s): (%s/%s) %s" % (self.name, msg.count(self.nickname), user, channel, msgLower))
if toSend:
helper.sendMaster("MATCH ACT %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0]))
def get(self, var):