Don't assume the bots nick is 5 chars long,
now the bot responds with the factoid when addressed by nick and !
This commit is contained in:
parent
5e92746f22
commit
dc653d3df1
|
@ -169,19 +169,20 @@ class Encyclopedia(callbacks.Plugin):
|
||||||
return self.databases[channel]
|
return self.databases[channel]
|
||||||
|
|
||||||
def addressed(self, recipients, text, irc):
|
def addressed(self, recipients, text, irc):
|
||||||
|
nlen = len(irc.nick)
|
||||||
if recipients[0] == '#':
|
if recipients[0] == '#':
|
||||||
text = text.strip()
|
text = text.strip()
|
||||||
if text.lower() == self.registryValue('prefixchar', channel=recipients) + irc.nick.lower():
|
if text.lower() == self.registryValue('prefixchar', channel=recipients) + irc.nick.lower():
|
||||||
return irc.nick.lower()
|
return irc.nick.lower()
|
||||||
if len(text) and text[0] == self.registryValue('prefixchar',channel=recipients):
|
if len(text) and text[0] == self.registryValue('prefixchar',channel=recipients):
|
||||||
text = text[1:]
|
text = text[1:]
|
||||||
if text.lower().startswith(irc.nick.lower()) and (len(text) < 5 or not text[5].isalnum()):
|
if text.lower().startswith(irc.nick.lower()) and (len(text) < nlen or not text[nlen].isalnum()):
|
||||||
t2 = text[5:].strip()
|
t2 = text[nlen:].strip()
|
||||||
if t2 and t2.find('>') != 0 and t2.find('|') != 0:
|
if t2 and t2.find('>') != 0 and t2.find('|') != 0:
|
||||||
text = text[5:].strip()
|
text = text[nlen:].strip()
|
||||||
return text
|
return text
|
||||||
if text.lower().startswith(irc.nick) and not text[5].isalnum():
|
if text.lower().startswith(irc.nick) and not text[nlen].isalnum():
|
||||||
return text[5:]
|
return text[nlen:]
|
||||||
return False
|
return False
|
||||||
else: # Private
|
else: # Private
|
||||||
if text.strip()[0] in str(conf.supybot.reply.whenAddressedBy.chars):
|
if text.strip()[0] in str(conf.supybot.reply.whenAddressedBy.chars):
|
||||||
|
|
Loading…
Reference in New Issue