From dc653d3df19f46d5691a0be974fb72205c47b18c Mon Sep 17 00:00:00 2001 From: Terence Simpson Date: Thu, 8 May 2008 20:41:50 +0100 Subject: [PATCH] Don't assume the bots nick is 5 chars long, now the bot responds with the factoid when addressed by nick and ! --- Encyclopedia/plugin.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Encyclopedia/plugin.py b/Encyclopedia/plugin.py index dd78730..65bf31e 100644 --- a/Encyclopedia/plugin.py +++ b/Encyclopedia/plugin.py @@ -169,19 +169,20 @@ class Encyclopedia(callbacks.Plugin): return self.databases[channel] def addressed(self, recipients, text, irc): + nlen = len(irc.nick) if recipients[0] == '#': text = text.strip() if text.lower() == self.registryValue('prefixchar', channel=recipients) + irc.nick.lower(): return irc.nick.lower() if len(text) and text[0] == self.registryValue('prefixchar',channel=recipients): text = text[1:] - if text.lower().startswith(irc.nick.lower()) and (len(text) < 5 or not text[5].isalnum()): - t2 = text[5:].strip() + if text.lower().startswith(irc.nick.lower()) and (len(text) < nlen or not text[nlen].isalnum()): + t2 = text[nlen:].strip() if t2 and t2.find('>') != 0 and t2.find('|') != 0: - text = text[5:].strip() + text = text[nlen:].strip() return text - if text.lower().startswith(irc.nick) and not text[5].isalnum(): - return text[5:] + if text.lower().startswith(irc.nick) and not text[nlen].isalnum(): + return text[nlen:] return False else: # Private if text.strip()[0] in str(conf.supybot.reply.whenAddressedBy.chars):