From: Ian Jackson Date: Thu, 30 May 2019 10:29:15 +0000 (+0100) Subject: blame: Move .last* update into a method X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~matthewv/git?a=commitdiff_plain;h=3a808bb740593679a63d7d8395ff61e73f1f0970;p=irc.git blame: Move .last* update into a method The code in troutq and blameq is very clone and hack. This change reduces it very slightly so that I can make my next change in only one place. No functional change. Signed-off-by: Ian Jackson --- diff --git a/commands.py b/commands.py index 02f2303..bb24cac 100755 --- a/commands.py +++ b/commands.py @@ -60,6 +60,10 @@ class FishPond: fishpond.DoS=0 fishpond.quotatime=0 + def note_last(fishpond, msg, cfg): + fishpond.last=msg + fishpond.last_cfg=cfg + # Check on fish stocks def fish_quota(pond): if pond.DoS: @@ -100,8 +104,7 @@ def troutq(bot, cmd, nick, conn, public, cfg): return me = bot.connection.get_nickname() trout_msg = random.choice(fishlist) - fishpond.last=trout_msg - fishpond.last_cfg=cfg + fishpond.note_last(trout_msg,cfg) # The bot won't trout or flirt with itself; if irc_lower(me) == irc_lower(target) or irc_lower(target) in synonyms: target = nick @@ -142,8 +145,7 @@ def slashq(bot, cmd, nick, conn, public, cfg): return me = bot.connection.get_nickname() slash_msg = random.choice(fishlist) - fishpond.last=slash_msg - fishpond.last_cfg=cfg + fishpond.note_last(slash_msg,cfg) # The bot won't slash people with themselves if irc_lower(who[0]) == irc_lower(who[1]): conn.notice(nick, "oooooh no missus!")