From d2e5620332806c4a9877860f57de371a77ae797c Mon Sep 17 00:00:00 2001 From: Matthew Vernon Date: Fri, 5 Oct 2012 15:48:08 +0100 Subject: [PATCH] add better self-trouting detection --- commands.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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]): -- 2.30.2