summaryrefslogtreecommitdiffstats
path: root/modules/seen.py
blob: 06dca3e1039dbcdaa57fa577a0af5fb3bd4b0bdc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/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/
"""

import time
from tools import deprecated

def seen(phenny, input):
    """.seen <nick> - Reports when <nick> was last seen."""
    nick = input.group(2)
    if not nick:
        return phenny.reply("Need a nickname to search for...")
    nick = nick.lower()

    if not hasattr(phenny, 'seen'):
        return phenny.reply("?")

    if phenny.seen.has_key(nick):
        channel, t = phenny.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)
        phenny.reply(msg)
    else: phenny.reply("Sorry, I haven't seen %s around." % nick)
seen.rule = (['seen'], r'(\S+)')

@deprecated
def f_note(self, origin, match, args):
    def note(self, origin, match, args):
        if not hasattr(self.bot, 'seen'):
            self.bot.seen = {}
        if origin.sender.startswith('#'):
            # if origin.sender == '#inamidst': return
            self.seen[origin.nick.lower()] = (origin.sender, time.time())

        # if not hasattr(self, 'chanspeak'):
        #     self.chanspeak = {}
        # if (len(args) > 2) and args[2].startswith('#'):
        #     self.chanspeak[args[2]] = args[0]

    try: note(self, origin, match, args)
    except Exception, e: print e
f_note.rule = r'(.*)'
f_note.priority = 'low'

if __name__ == '__main__':
    print __doc__.strip()