Changeset 151
- Timestamp:
- 06/11/08 19:12:21 (2 months ago)
- Files:
-
- trunk/antimatter/luke/myplugs/libtracker/auth.py (modified) (4 diffs)
- trunk/antimatter/luke/myplugs/libtracker/tracker.py (modified) (1 diff)
- trunk/antimatter/luke/myplugs/libtracker/user.py (modified) (1 diff)
- trunk/antimatter/luke/myplugs/libtracker/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/antimatter/luke/myplugs/libtracker/auth.py
r149 r151 1 1 """ Simple user authentication script """ 2 from time import time, gmtime 3 2 4 from gozerbot.generic import waitforuser, rlog 5 3 6 from user import User 4 7 5 8 authenticated = {} 9 #TODO: Place user objects on disk instead of in a dict? 6 10 7 11 def authenticate_name(bot, ievent): … … 12 16 user = check_auth(ievent) 13 17 if (not user == None): 14 bot.say(ievent.nick, "You're still authenticated") 15 #TODO: Tell how long until authentication ends 18 until = gmtime(86400 - (time() - user.lastauth)) 19 bot.say(ievent.nick, "You're still authenticated for " + str(until[3]) + "h:" \ 20 + str(until[4]) + "m:" + str(until[5]) + "s") 21 #TODO: Grab max auth time from a config file 16 22 return True 17 23 bot.say(ievent.nick, "Username?") … … 29 35 username = reply.txt 30 36 31 set_auth(ievent, User(username)) 37 bot.say(ievent.nick, "You have been authenticated for 1 day.") 38 set_auth(ievent, username) 32 39 33 40 return True … … 44 51 return user 45 52 46 def set_auth(ievent, user): 53 def get_auth(bot,ievent): 54 """ Checks to see if the user is already authenticated 55 Input: Ircevent 56 Output: bool 57 """ 58 if (check_auth(ievent) == None): 59 return False 60 else: 61 return True 62 63 def set_auth(ievent, username): 47 64 """ Puts the userhost into the authentication dictionary 48 65 Input: Ircevent, User 49 66 """ 67 user = User(username, time()) 50 68 authenticated[ievent.userhost] = user trunk/antimatter/luke/myplugs/libtracker/tracker.py
r150 r151 1 1 """ Time tracker script """ 2 2 3 from gozerbot.callbacks import callbacks 3 4 from gozerbot.commands import cmnds 5 4 6 import myplugs.libtracker.auth as auth 5 7 6 def start_tracker(bot, ievent): 8 def init(): 9 callbacks.add("PRIVMSG", tracker, auth.get_auth, threaded=True) 10 11 def tracker(bot, ievent): 7 12 user = auth.check_auth(ievent) 8 if (user == None): 9 ievent.reply("I'm sorry Dave, but I'm afraid you haven't \ 10 authenticated yet") 11 return 12 ievent.reply("Tracking for " + user.name) 13 ievent.reply("I'm watching you, " + user.name) 13 14 14 15 def authenticate(bot, ievent): 15 16 auth.authenticate_name(bot,ievent) 16 17 17 cmnds.add('tracker', start_tracker, 'USER')18 18 cmnds.add('auth', authenticate, 'USER') trunk/antimatter/luke/myplugs/libtracker/user.py
r146 r151 1 1 class User: 2 2 3 def __init__(self, name ):3 def __init__(self, name, time): 4 4 self.name = name 5 self.lastauth = time 5 6 6 7 def addTime(self): trunk/antimatter/luke/myplugs/libtracker/__init__.py
r137 r151 1 __all__ = ['auth', ' tracker']1 __all__ = ['auth', 'user', 'tracker']