askcompu

Untitled

Jul 21st, 2015
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.67 KB | None | 0 0
  1. #!/usr/bin/env python
  2. """
  3. seen.py - Phenny Seen Module
  4. Copyright 2008, Sean B. Palmer, inamidst.com
  5. Licensed under the Eiffel Forum License 2.
  6.  
  7. http://inamidst.com/phenny/
  8. """
  9.  
  10. import time
  11. from tools import deprecated
  12.  
  13. @deprecated
  14. def f_seen(self, origin, match, args):
  15.     """.seen <nick> - Reports when <nick> was last seen."""
  16.     if origin.sender == '#talis': return
  17.     if match.lastindex is None or match.lastindex < 2:
  18.         self.msg(origin.sender, "You didn't tell me who to look for, silly!")
  19.         return
  20.     nick = match.group(2).lower()
  21.     if not hasattr(self, 'seen'):
  22.         return self.msg(origin.sender, '?')
  23.     if nick in self.seen:
  24.         channel, t = self.seen[nick]
  25.         t = time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime(t))
  26.  
  27.         msg = "I last saw %s at %s on %s" % (nick, t, channel)
  28.         self.msg(origin.sender, str(origin.nick) + ': ' + msg)
  29.     else: self.msg(origin.sender, "Sorry, I haven't seen %s around." % nick)
  30. f_seen.rule = (['seen'], r'(\S+)')
  31.  
  32. @deprecated
  33. def f_note(self, origin, match, args):
  34.     def note(self, origin, match, args):
  35.         if not hasattr(self.bot, 'seen'):
  36.             self.bot.seen = {}
  37.         if origin.sender.startswith('#'):
  38.             # if origin.sender == '#inamidst': return
  39.             self.seen[origin.nick.lower()] = (origin.sender, time.time())
  40.  
  41.         # if not hasattr(self, 'chanspeak'):
  42.         #     self.chanspeak = {}
  43.         # if (len(args) > 2) and args[2].startswith('#'):
  44.         #     self.chanspeak[args[2]] = args[0]
  45.  
  46.     try: note(self, origin, match, args)
  47.     except Exception as e: print(e)
  48. f_note.rule = r'(.*)'
  49. f_note.priority = 'low'
  50.  
  51. if __name__ == '__main__':
  52.     print(__doc__.strip())
Advertisement
Add Comment
Please, Sign In to add comment