Commits

Filip Brcic committed 9887708

put .seen into persistent storage

Comments (0)

Files changed (1)

             )
 
     def execute(self, bot, input):
-        if not hasattr(self.bot, 'seen'):
-            self.bot.seen = dict()
+        if not hasattr(bot, 'db'):
+            return
+        if bot.db.has_key('seen'):
+            seen = bot.db['seen']
+        else:
+            seen = dict()
         if input.sender.startswith('#'):
-            self.bot.seen[input.nick.lower()] = (input.sender, time.time())
+            seen[input.nick.lower()] = (input.sender, time.time())
+            self.bot.db['seen'] = seen
 
 class IRCSeenModule(IRCModule):
     def __init__(self, bot):
         if nick is None:
             return
         nick = nick.lower()
-        if not hasattr(self.bot, 'seen'):
+        if not hasattr(bot, 'db'):
+            return
+        if not bot.db.has_key('seen'):
             bot.say('?')
             return
-        if self.bot.seen.has_key(nick):
-            channel, t = self.bot.seen[nick]
+        if bot.db['seen'].has_key(nick):
+            channel, t = bot.db['seen'][nick]
             t = time.ctime(t)
             msg = '%s was last seen at %s in %s' % (nick, t, channel)
             bot.say(msg)