Don't number if there's only one factoid, and added a factoidPrefix configuration variable.

This commit is contained in:
Jeremy Fincher 2004-07-02 13:58:29 +00:00
parent cc193c39ea
commit 88751622c7

View File

@ -77,6 +77,9 @@ conf.registerChannelValue(conf.supybot.plugins.Factoids,
the bot will reply to invalid commands by searching for a factoid; the bot will reply to invalid commands by searching for a factoid;
basically making the whatis unnecessary when you want all factoids for a basically making the whatis unnecessary when you want all factoids for a
given key.""")) given key."""))
conf.registerChannelValue(conf.supybot.plugins.Factoids,
'factoidPrefix', registry.StringWithSpaceOnRight('could be ', """Determines
the string that factoids will be introduced by."""))
class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg): class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
def __init__(self): def __init__(self):
@ -171,13 +174,18 @@ class Factoids(plugins.ChannelDBHandler, callbacks.Privmsg):
irc.error('That\'s not a valid number for that key.') irc.error('That\'s not a valid number for that key.')
return return
else: else:
factoidsS = [] intro = self.registryValue('factoidPrefix', channel)
counter = 1 prefix = '%r %s' % (key, intro)
for factoid in factoids: if len(factoids) == 1:
factoidsS.append('(#%s) %s' % (counter, factoid)) irc.reply(prefix + factoids[0])
counter += 1 else:
irc.replies(factoidsS, prefixer='%r could be ' % key, factoidsS = []
joiner=', or ', onlyPrefixFirst=True) counter = 1
for factoid in factoids:
factoidsS.append('(#%s) %s' % (counter, factoid))
counter += 1
irc.replies(factoidsS, prefixer=prefix,
joiner=', or ', onlyPrefixFirst=True)
elif error: elif error:
irc.error('No factoid matches that key.') irc.error('No factoid matches that key.')