askcompu

Untitled

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