askcompu

Untitled

Jul 10th, 2015
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.53 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.     nick = match.group(2).lower()
  18.     if not hasattr(self, 'seen'):
  19.         return self.msg(origin.sender, '?')
  20.     if nick in self.seen:
  21.         channel, t = self.seen[nick]
  22.         t = time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime(t))
  23.  
  24.         msg = "I last saw %s at %s on %s" % (nick, t, channel)
  25.         self.msg(origin.sender, str(origin.nick) + ': ' + msg)
  26.     else: self.msg(origin.sender, "Sorry, I haven't seen %s around." % nick)
  27. f_seen.rule = (['seen'], r'(\S+)')
  28.  
  29. @deprecated
  30. def f_note(self, origin, match, args):
  31.     def note(self, origin, match, args):
  32.         if not hasattr(self.bot, 'seen'):
  33.             self.bot.seen = {}
  34.         if origin.sender.startswith('#'):
  35.             # if origin.sender == '#inamidst': return
  36.             self.seen[origin.nick.lower()] = (origin.sender, time.time())
  37.  
  38.         # if not hasattr(self, 'chanspeak'):
  39.         #     self.chanspeak = {}
  40.         # if (len(args) > 2) and args[2].startswith('#'):
  41.         #     self.chanspeak[args[2]] = args[0]
  42.  
  43.     try: note(self, origin, match, args)
  44.     except Exception as e: print(e)
  45. f_note.rule = r'(.*)'
  46. f_note.priority = 'low'
  47.  
  48. if __name__ == '__main__':
  49.     print(__doc__.strip())
Advertisement
Add Comment
Please, Sign In to add comment