Fix counting of nickname highlights

This commit is contained in:
Mark Veidemanis 2017-12-02 19:49:00 +00:00
parent cc75535bcf
commit 9506d3d1f4
1 changed files with 12 additions and 9 deletions

View File

@ -88,9 +88,10 @@ class IRCBot(IRCClient):
else: else:
if config["HighlightNotifications"]: if config["HighlightNotifications"]:
msgLower = msg.lower() msgLower = msg.lower()
if self.nickname.lower() in msgLower: nickLower = self.nickname.lower()
msgLower = msgLower.replace(self.nickname, "{"+self.nickname+"}") if nickLower in msgLower:
helper.sendMaster("NICK PRV %s (T:%s): (%s/%s) %s" % (self.name, msg.count(self.nickname), user, channel, msgLower)) msgLower = msgLower.replace(nickLower, "{"+nickLower+"}")
helper.sendMaster("NICK PRV %s (T:%s): (%s/%s) %s" % (self.name, msgLower.count(nickLower), user, channel, msgLower))
if toSend: if toSend:
helper.sendMaster("MATCH PRV %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0])) helper.sendMaster("MATCH PRV %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0]))
@ -101,9 +102,10 @@ class IRCBot(IRCClient):
else: else:
if config["HighlightNotifications"]: if config["HighlightNotifications"]:
msgLower = msg.lower() msgLower = msg.lower()
if self.nickname.lower() in msgLower: nickLower = self.nickname.lower()
msgLower = msgLower.replace(self.nickname, "{"+self.nickname+"}") if nickLower in msgLower:
helper.sendMaster("NICK NOT %s (T:%s): (%s/%s) %s" % (self.name, msg.count(self.nickname), user, channel, msgLower)) msgLower = msgLower.replace(nickLower, "{"+nickLower+"}")
helper.sendMaster("NICK NOT %s (T:%s): (%s/%s) %s" % (self.name, msgLower.count(nickLower), user, channel, msgLower))
if toSend: if toSend:
helper.sendMaster("MATCH NOT %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0])) helper.sendMaster("MATCH NOT %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0]))
@ -114,9 +116,10 @@ class IRCBot(IRCClient):
else: else:
if config["HighlightNotifications"]: if config["HighlightNotifications"]:
msgLower = msg.lower() msgLower = msg.lower()
if self.nickname.lower() in msgLower: nickLower = self.nickname.lower()
msgLower = msgLower.replace(self.nickname, "{"+self.nickname+"}") if nickLower in msgLower:
helper.sendMaster("NICK ACT %s (T:%s): (%s/%s) %s" % (self.name, msg.count(self.nickname), user, channel, msgLower)) msgLower = msgLower.replace(nickLower, "{"+nickLower+"}")
helper.sendMaster("NICK ACT %s (T:%s): (%s/%s) %s" % (self.name, msgLower.count(nickLower), user, channel, msgLower))
if toSend: if toSend:
helper.sendMaster("MATCH ACT %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0])) helper.sendMaster("MATCH ACT %s (U:%s T:%s): (%s/%s) %s" % (self.name, toSend[1], toSend[2], user, channel, toSend[0]))