From 3a808bb740593679a63d7d8395ff61e73f1f0970 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 30 May 2019 11:29:15 +0100 Subject: [PATCH] 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 --- commands.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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!") -- 2.30.2