From: Matthew Vernon Date: Fri, 5 Oct 2012 14:48:08 +0000 (+0100) Subject: add better self-trouting detection X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~matthewv/git?p=irc.git;a=commitdiff_plain;h=d2e5620332806c4a9877860f57de371a77ae797c add better self-trouting detection --- diff --git a/commands.py b/commands.py index e8293ef..f015b89 100755 --- a/commands.py +++ b/commands.py @@ -61,6 +61,9 @@ def fish_quota(pond): pond.cur_fish=pond.max_fish pond.quotatime=time.time() +# List of things the bot might be called to work round the self-trouting code +synonyms=["itself","the bot"] + # trout someone, or flirt with them def troutq(bot, cmd, nick, conn, public, cfg): fishlist=cfg[0] @@ -86,7 +89,7 @@ def troutq(bot, cmd, nick, conn, public, cfg): trout_msg = random.choice(fishlist) fishpond.last=trout_msg # The bot won't trout or flirt with itself; - if irc_lower(me) == irc_lower(target): + if irc_lower(me) == irc_lower(target) or irc_lower(target) in synonyms: target = nick # There's a chance the game may be given away if the request was not # public... @@ -132,7 +135,7 @@ def slashq(bot, cmd, nick, conn, public, cfg): return # The bot won't slash with itself, instead slashing the requester for n in [0,1]: - if irc_lower(me) == irc_lower(who[n]): + if irc_lower(me) == irc_lower(who[n]) or irc_lower(who[n]) in synonyms: who[n] = nick # Perhaps someone asked to slash themselves with the bot then we get if irc_lower(who[0]) == irc_lower(who[1]):