chiark / gitweb /
FishPond: introduce new class and use in Servus-chiark
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 30 May 2019 10:08:23 +0000 (11:08 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 30 May 2019 10:15:59 +0000 (11:15 +0100)
The configuration class `fish' appears in every bot, but it also
contains initial values of state variables used by the implementation.

Move those into their own class, and make it a base class of
Servus-chiark's pond.  Since we are duck typing, it is OK to not yet
update the other bots.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Servus-chiark.py
commands.py

index 6d3af24c258625c62231c49635d0b79722e6337c..45b19a428e799527650e5304d9bfaa5f2b34e78a 100755 (executable)
@@ -42,17 +42,13 @@ import commands as c
 
 # This fishpond is shared between trouts and flirts.  It doesn't have to be;
 # you can define as many ponds as you like.
-class fish:
+class fish (c.FishPond):
        cur_fish=5
        max_fish=5
        nofish_time=60
        fish_time_inc=60
        fish_inc=2
-       DoS=0
        Boring_Git='Nobody'
-       quotatime=0
-       last=""
-       last_cfg=None
 
 # load the "blame" details for a file
 def loadblame(filename):
index 964dacfa41a4c1e782d0ce643798f29606672802..6c5653dc9dd42119b80d1ea6a784007e762a1205 100755 (executable)
@@ -53,6 +53,12 @@ def infoq(bot, cmd, nick, conn, public, karma):
        (bot.revision.split()[1], bot.channel, conn.get_nickname(),
         bot.owner, len(karma.keys())))
 
+class FishPond:
+    DoS=0
+    quotatime=0
+    last=""
+    last_cfg=None
+
 # Check on fish stocks
 def fish_quota(pond):
     if pond.DoS: