2008-02-21 07:06:33 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
"""
|
|
|
|
seen.py - Phenny Seen Module
|
|
|
|
Copyright 2008, Sean B. Palmer, inamidst.com
|
|
|
|
Licensed under the Eiffel Forum License 2.
|
|
|
|
|
|
|
|
http://inamidst.com/phenny/
|
|
|
|
"""
|
|
|
|
|
2013-01-01 15:19:06 -05:00
|
|
|
import time, os, shelve
|
2008-02-21 07:06:33 -05:00
|
|
|
from tools import deprecated
|
|
|
|
|
|
|
|
@deprecated
|
|
|
|
def f_seen(self, origin, match, args):
|
2012-01-03 14:09:34 -05:00
|
|
|
""".seen <nick> - Reports when <nick> was last seen."""
|
|
|
|
nick = match.group(2).lower()
|
|
|
|
if not hasattr(self, 'seen'):
|
|
|
|
return self.msg(origin.sender, '?')
|
|
|
|
if nick in self.seen:
|
|
|
|
channel, t = self.seen[nick]
|
|
|
|
t = time.strftime('%Y-%m-%d %H:%M:%S UTC', time.gmtime(t))
|
|
|
|
|
|
|
|
msg = "I last saw %s at %s on %s" % (nick, t, channel)
|
|
|
|
self.msg(origin.sender, str(origin.nick) + ': ' + msg)
|
|
|
|
else: self.msg(origin.sender, "Sorry, I haven't seen %s around." % nick)
|
2008-02-21 07:06:33 -05:00
|
|
|
f_seen.rule = (['seen'], r'(\S+)')
|
|
|
|
|
|
|
|
@deprecated
|
|
|
|
def f_note(self, origin, match, args):
|
2012-01-03 14:09:34 -05:00
|
|
|
def note(self, origin, match, args):
|
|
|
|
if not hasattr(self.bot, 'seen'):
|
2013-01-01 15:19:06 -05:00
|
|
|
fn = self.nick + '-' + self.config.host + '.seen.db'
|
|
|
|
path = os.path.join(os.path.expanduser('~/.phenny'), fn)
|
|
|
|
self.bot.seen = shelve.open(path)
|
2012-01-03 14:09:34 -05:00
|
|
|
if origin.sender.startswith('#'):
|
|
|
|
self.seen[origin.nick.lower()] = (origin.sender, time.time())
|
2013-01-01 15:19:06 -05:00
|
|
|
self.seen.sync()
|
2012-01-03 14:09:34 -05:00
|
|
|
|
|
|
|
try: note(self, origin, match, args)
|
|
|
|
except Exception as e: print(e)
|
2008-02-21 07:06:33 -05:00
|
|
|
f_note.rule = r'(.*)'
|
|
|
|
f_note.priority = 'low'
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-01-03 14:09:34 -05:00
|
|
|
print(__doc__.strip())
|