Software Freedom Law Center

Changeset 151

Show
Ignore:
Timestamp:
06/11/08 19:12:21 (2 months ago)
Author:
landon
Message:

Inserted a callback so users could stay authenticated for periods of time while luke checks their messages

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/antimatter/luke/myplugs/libtracker/auth.py

    r149 r151  
    11""" Simple user authentication script """ 
     2from time import time, gmtime 
     3 
    24from gozerbot.generic import waitforuser, rlog 
     5 
    36from user import User 
    47 
    58authenticated = {} 
     9#TODO: Place user objects on disk instead of in a dict? 
    610 
    711def authenticate_name(bot, ievent): 
     
    1216    user = check_auth(ievent) 
    1317    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 
    1622        return True 
    1723    bot.say(ievent.nick, "Username?") 
     
    2935        username = reply.txt 
    3036 
    31     set_auth(ievent, User(username)) 
     37    bot.say(ievent.nick, "You have been authenticated for 1 day.") 
     38    set_auth(ievent, username) 
    3239 
    3340    return True 
     
    4451    return user 
    4552 
    46 def set_auth(ievent, user): 
     53def 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 
     63def set_auth(ievent, username): 
    4764    """ Puts the userhost into the authentication dictionary 
    4865    Input: Ircevent, User 
    4966    """ 
     67    user = User(username, time()) 
    5068    authenticated[ievent.userhost] = user 
  • trunk/antimatter/luke/myplugs/libtracker/tracker.py

    r150 r151  
    11""" Time tracker script """ 
    22 
     3from gozerbot.callbacks import callbacks 
    34from gozerbot.commands import cmnds 
     5 
    46import myplugs.libtracker.auth as auth 
    57 
    6 def start_tracker(bot, ievent): 
     8def init(): 
     9    callbacks.add("PRIVMSG", tracker, auth.get_auth, threaded=True) 
     10 
     11def tracker(bot, ievent): 
    712    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) 
    1314 
    1415def authenticate(bot, ievent): 
    1516    auth.authenticate_name(bot,ievent) 
    1617 
    17 cmnds.add('tracker', start_tracker, 'USER') 
    1818cmnds.add('auth', authenticate, 'USER') 
  • trunk/antimatter/luke/myplugs/libtracker/user.py

    r146 r151  
    11class User: 
    22 
    3     def __init__(self, name): 
     3    def __init__(self, name, time): 
    44        self.name = name 
     5        self.lastauth = time 
    56 
    67    def addTime(self): 
  • trunk/antimatter/luke/myplugs/libtracker/__init__.py

    r137 r151  
    1 __all__ = ['auth', 'tracker'] 
     1__all__ = ['auth', 'user', 'tracker'] 

SFLC Main Page

[frdm] Support SFLC