chiark / gitweb /
blame: Move .last* update into a method
[irc.git] / commands.py
index 02f23034a2428f5f45aa4fb1ac9cc69b4e1ff755..bb24cac2d0e4c4c7a247da5528fe0008aaf84483 100755 (executable)
@@ -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!")