Exemple #1
0
def handle_addshop(bot, ievent):
    """ shop-add <username> <item> .. add items to shop list of <username>"""
    if len(ievent.args) < 2:
        ievent.missing('<username> <item>')
        return
    else:
        who = ievent.args[0]
        what = ' '.join(ievent.args[1:])
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost of %s" % who)
        return
    # get username of use giviing the command
    username = users.getname(ievent.userhost)
    # get username of person we want to knwo the shop list of
    whoname = users.getname(userhost)
    if not whoname:
        ievent.reply("can't find user for %s" % userhost)
        return
    if users.permitted(userhost, username, 'shop'):
        shops[whoname] = what
        shops.save()
        ievent.reply('shop item added')
    else:
        ievent.reply("%s does not share shopping list with %s" % (who, \
username))
Exemple #2
0
def handle_settodo(bot, ievent):
    """ todo-set <name> <txt> .. add a todo to another user's todo list"""
    try:
        who = ievent.args[0]
        what = ' '.join(ievent.args[1:])
    except IndexError:
        ievent.missing('<nick> <what>')
        return
    if not what:
        ievent.missing('<nick> <what>')
        return
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost for %s" % who)
        return
    whouser = users.getname(userhost)
    if not whouser:
        ievent.reply("can't find user for %s" % userhost)
        return
    name = users.getname(ievent.userhost)
    if not users.permitted(userhost, name, 'todo'):
        ievent.reply("%s doesn't permit todo sharing for %s " % \
(who, name))
        return
    what = "%s: %s" % (ievent.nick, what)
    ttime = strtotime(what)
    nr = 0
    if not ttime == None:
        ievent.reply('time detected ' + time.ctime(ttime))
        what = striptime(what)
        alarmnr = alarms.add(bot.name, who, ttime, what)
        nr = todo.add(whouser, what, ttime, alarmnr=alarmnr)
    else:
        nr = todo.add(whouser, what, 0)
    ievent.reply('todo item %s added' % nr)
Exemple #3
0
def handle_settodo(bot, ievent):
    """ todo-set <name> <txt> .. add a todo to another user's todo list"""
    try:
        who = ievent.args[0]
        what = ' '.join(ievent.args[1:])
    except IndexError:
        ievent.missing('<nick> <what>')
        return
    if not what:
        ievent.missing('<nick> <what>')
        return
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost for %s" % who)
        return
    whouser = users.getname(userhost)
    if not whouser:
        ievent.reply("can't find user for %s" % userhost)
        return
    name = users.getname(ievent.userhost)
    if not users.permitted(userhost, name, 'todo'):
        ievent.reply("%s doesn't permit todo sharing for %s " % \
(who, name))
        return
    what = "%s: %s" % (ievent.nick, what)
    ttime = strtotime(what)
    nr = 0
    if not ttime  == None:
        ievent.reply('time detected ' + time.ctime(ttime))
        what = striptime(what)
        alarmnr = alarms.add(bot.name, who, ttime, what)
        nr = todo.add(whouser, what, ttime, alarmnr=alarmnr)
    else:
        nr = todo.add(whouser, what, 0)
    ievent.reply('todo item %s added' % nr)
Exemple #4
0
def handle_addshop(bot, ievent):
    """ shop-add <username> <item> .. add items to shop list of <username>"""
    if len(ievent.args) < 2:
        ievent.missing('<username> <item>')
        return
    else:
        who = ievent.args[0]
        what = ' '.join(ievent.args[1:])
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost of %s" % who)
        return
    # get username of use giviing the command
    username = users.getname(ievent.userhost)
    # get username of person we want to knwo the shop list of
    whoname = users.getname(userhost)
    if not whoname:
        ievent.reply("can't find user for %s" % userhost)
        return
    if users.permitted(userhost, username, 'shop'):
        shops[whoname] = what
        shops.save()
        ievent.reply('shop item added')
    else:
        ievent.reply("%s does not share shopping list with %s" % (who, \
username))
Exemple #5
0
def handle_got(bot, ievent):
    """ got <listofnrs> .. remove items from shoplist """
    if len(ievent.args) == 0:
        ievent.missing('<list of nrs>')
        return
    try:
        nrs = []
        for i in ievent.args:
            nrs.append(int(i))
    except ValueError:
        ievent.reply('%s is not an integer' % i)
        return
    username = users.getname(ievent.userhost)
    try:
        shop = shops[username]
    except KeyError:
        ievent.reply('nothing to shop ;]')
        return
    if not shop:
        ievent.reply("nothing to shop ;]")
        return
    nrs.sort()
    nrs.reverse()
    teller = 0
    for i in range(len(shop)-1, -1 , -1):
        if i in nrs:
            try:
                del shop[i]
                teller += 1
            except IndexError:
                pass
    shops.save()
    ievent.reply('%s shop item(s) deleted' % teller)
def handle_addshare(bot, ievent):
    """ share a project with another user """
    username = users.getname(ievent.userhost)
    try:
        project, otheruser = ievent.rest.split(' ', 1)
    except ValueError:
        ievent.missing('<projectname> <user>')
        return
    project = project.strip().lower()
    if hascontrib(username, project):
        ievent.reply('only project owner can share a project')
        return
    if not hasproject(username, project):
        ievent.reply('no project %s' % project)
        return
    if not users.exist(otheruser):
        ievent.reply('unknown user %s' % otheruser)
        return
    if hasproject(otheruser, project) or \
    hascontrib(otheruser, project):
        ievent.reply('%s already has a project named %s' \
        % (otheruser, project))
        return
    addshare(username, project, otheruser)
    desc = getdesc(username, project) or project
    ievent.reply('sharing %s with %s' % (desc, otheruser))
Exemple #7
0
def handle_time(bot, ievent):

    """ show current time """

    authuser = users.getname(ievent.userhost)

    if authuser:

        if ievent.rest:
            if users.exist(ievent.rest.lower()):
                username = ievent.rest.lower()
            else:
                ievent.reply("We don't have a user %s" % ievent.rest)
                return
        else:
            username = authuser

        userstate = UserState(username)

        try:
            tz = userstate['TZ']
        except KeyError:
            if username == authuser:
                tz = handle_ask_timezone(bot, ievent)
                if tz and set_timezone(bot, ievent, userstate, tz):
                    tz = userstate['TZ']
                else:
                    return
            else:
                ievent.reply("%s doesn't have a timezone set" % username)
                return
        ievent.reply(get_time(tz, username, authuser))

    else:
        ievent.reply(get_time('UTC', '', ''))
Exemple #8
0
def handle_logtime(bot, ievent):
    """ show log from a certain time """
    if not logs:
        ievent.reply('log plugin is not enabled')
        return
    if ievent.channel not in logs.loglist:
        ievent.reply('logging is not enabled in %s' % ievent.channel)
        return
    fromtime = strtotime(ievent.rest)
    if not fromtime:
        ievent.reply("can't detect time")
        return
    result = logs.fromtimewithbot(ievent.channel, fromtime)
    if result:
        username = users.getname(ievent.userhost)
        res = []
        for i in result:
            if i[2] == 'bot':
                txt = i[4]
            else:
                nr = i[4].find(' ')
                txt = i[4][nr:].strip()
            res.append("[%s] <%s> %s" % (hourmin(float(i[1])), i[2], txt))
        ievent.reply(res)
        return
    ievent.reply('no data found')
Exemple #9
0
def handle_addshare(bot, ievent):
    """ share a project with another user """
    username = users.getname(ievent.userhost)
    try:
        project, otheruser = ievent.rest.split(' ', 1)
    except ValueError:
        ievent.missing('<projectname> <user>')
        return
    project = project.strip().lower()
    if hascontrib(username, project):
        ievent.reply('only project owner can share a project')
        return
    if not hasproject(username, project):
        ievent.reply('no project %s' % project)
        return
    if not users.exist(otheruser):
        ievent.reply('unknown user %s' % otheruser)
        return
    if hasproject(otheruser, project) or \
    hascontrib(otheruser, project):
        ievent.reply('%s already has a project named %s' \
        % (otheruser, project))
        return
    addshare(username, project, otheruser)
    desc = getdesc(username, project) or project
    ievent.reply('sharing %s with %s' % (desc, otheruser))
Exemple #10
0
def handle_lists(bot, ievent):
    """ lists <listname> [',' <item>] .. global lists"""
    if not ievent.rest:
        ievent.missing("<listname> [',' <item>]")
        return
    username = users.getname(ievent.userhost)
    try:
        listname, item = ievent.rest.split(',', 1)
    except ValueError:
        l = getlist(username, ievent.rest)
        if not l:
            ievent.reply('no %s list available' % ievent.rest)
            return
        result = []
        for i in l:
            result.append("%s) %s" % (i.indx, i.item))
        ievent.reply(result)
        return
    listname = listname.strip().lower()
    item = item.strip()
    if not listname or not item:
        ievent.missing("<listname> [',' <item>]")
        return
    result = 0
    try:
        result = addtolist(username, listname, item)
    except Exception, ex:
        handle_exception()
        ievent.reply('ERROR: %s' % str(ex))
        return
Exemple #11
0
def handle_report(bot, ievent):
    """ display project report """
    username = users.getname(ievent.userhost)
    if not ievent.rest:
        result = []
        l = getprojects(username)
        for project in l:
            desc = getdesc(username, project) or project
            report = gethourslist(username, project)
            result.append('%s: %s' % (desc, ' '.join(report)))
        l = getcontrib(username)
        for project in l:
            owner = getowner(username, project)
            desc = getdesc(owner, project) or project
            report = gethourslist(owner, project)
            result.append('%s: %s' % (desc, ' '.join(report)))
        if result:
            ievent.reply('', result, dot=True)
        else:
            ievent.reply('no projects found')
    else:
        project = ievent.rest.strip().lower()
        if hasproject(username, project):
            owner = username
        elif hascontrib(username, project):
            owner = getowner(username, project)
        else:
            ievent.reply('no project %s' % project)
            return
        desc = getdesc(owner, project) or project
        report = gethourslist(owner, project)
        ievent.reply('%s: ' % desc, report, dot=True)
Exemple #12
0
def handle_listsdel(bot, ievent):
    """ lists-del <listname> ',' <listofnrs> .. remove items with indexnr \
from list """
    if not ievent.rest:
        ievent.missing('<listofnrs>')
        return
    try:
        nrs = []
        for i in ievent.rest.split():
            nrs.append(int(i))
    except ValueError:
        ievent.reply('%s is not an integer' % i)
        return
    username = users.getname(ievent.userhost)
    nrs.sort()
    failed = []
    itemsdeleted = 0
    try:
        for i in nrs:
            result = delfromlist(username, i)
            if not result:
                failed.append(str(i))
            else:
                itemsdeleted += 1
    except Exception, ex:
        handle_exception()
        ievent.reply('ERROR: %s' % str(ex))
        return
def handle_bd(bot, ievent):
    """ bd [<nr|user>] .. show birthday of month or user """
    if not ievent.rest:    
        handle_checkbd(bot, ievent)
        return
    try:
        int(ievent.args[0])
        handle_checkbd2(bot, ievent)
        return
    except (IndexError, ValueError):
        who = ievent.args[0].lower()
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("don't know userhost of %s" % who)
        return
    name = users.getname(userhost)
    if not name:
        ievent.reply("can't find user for %s" % userhost)
        return
    s = create_session()
    bd = s.query(Birthday).filter(Birthday.name==name).first()
    if bd:
        ievent.reply('birthday of %s is %s' % (who, bd.birthday))
    else:
        ievent.reply('no birthday know for %s' % name)
def handle_age(bot, ievent):
    """ age <nick> .. show age of user """
    try:
        who = ievent.args[0].lower()
    except IndexError:
        ievent.missing('<nick>')
        return
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("don't know userhost of %s" % who)
        return
    name = users.getname(userhost)
    if not name:
        ievent.reply("can't find user for %s" % userhost)
        return
    s = create_session()
    bd = s.query(Birthday).filter(Birthday.name==name).first()
    try:
        birthday = bd.birthday
    except (TypeError, AttributeError):
        ievent.reply("can't find birthday data for %s" % who)
        return
    btime = strtotime(birthday)
    if btime == None:
        ievent.reply("can't make a date out of %s" % birthday)
        return
    age = int(time.time()) - int(btime)
    ievent.reply("age of %s is %s" % (who, elapsedstring(age, ywd=True)))
Exemple #15
0
def handle_time(bot, ievent):
    """ show current time """

    authuser = users.getname(ievent.userhost)

    if authuser:

        if ievent.rest:
            if users.exist(ievent.rest.lower()):
                username = ievent.rest.lower()
            else:
                ievent.reply("We don't have a user %s" % ievent.rest)
                return
        else:
            username = authuser

        userstate = UserState(username)

        try:
            tz = userstate['TZ']
        except KeyError:
            if username == authuser:
                tz = handle_ask_timezone(bot, ievent)
                if tz and set_timezone(bot, ievent, userstate, tz):
                    tz = userstate['TZ']
                else:
                    return
            else:
                ievent.reply("%s doesn't have a timezone set" % username)
                return
        ievent.reply(get_time(tz, username, authuser))

    else:
        ievent.reply(get_time('UTC', '', ''))
Exemple #16
0
def handle_todosettime(bot, ievent):
    """ todo-settime [<channel|name>] <itemnr> <timestring> .. set time \
        on todo item """
    ttime = strtotime(ievent.txt)
    if ttime == None:
        ievent.reply("can't detect time")
        return
    txt = striptime(ievent.txt)
    try:
        (who, itemnr) = txt.split()
    except ValueError:
        try:
            (itemnr, ) = txt.split()
            who = users.getname(ievent.userhost)
        except ValueError:
            ievent.missing('[<channe|namel>] <itemnr> <timestring>')
            return
    try:
        itemnr = int(itemnr)
    except ValueError:
        ievent.missing('[<channel|name>] <itemnr> <timestring>')
        return
    who = who.lower()
    if not todo.settime(who, itemnr, ttime):
        ievent.reply('no todo %s found for %s' % (itemnr, who))
        return
    ievent.reply('time of todo %s set to %s' % (itemnr, time.ctime(ttime)))
Exemple #17
0
def handle_logtime(bot, ievent):
    """ show log from a certain time """
    if not logs:
        ievent.reply('log plugin is not enabled')
        return
    if ievent.channel not in logs.loglist:
        ievent.reply('logging is not enabled in %s' % ievent.channel)
        return
    fromtime = strtotime(ievent.rest)
    if not fromtime:
        ievent.reply("can't detect time")
        return
    result = logs.fromtimewithbot(ievent.channel, fromtime)
    if result:
        username = users.getname(ievent.userhost)
        res = []
        for i in result:
            if i[2] == 'bot':
                txt = i[4]
            else:
                nr = i[4].find(' ')
                txt = i[4][nr:].strip()
            res.append("[%s] <%s> %s" % (hourmin(float(i[1])), i[2], txt))
        ievent.reply(res)
        return
    ievent.reply('no data found')
Exemple #18
0
def handle_merge(bot, ievent):
    """ user-merge <name> <nick> .. merge the userhost into a already \
        existing user """
    if len(ievent.args) != 2:
        ievent.missing('<name> <nick>')
        return  
    name, nick = ievent.args
    name = name.lower()
    if users.gotperm(name, 'OPER') and not users.allowed(ievent.userhost, \
'OPER'):
        ievent.reply("only OPER perm can merge with OPER user")
        return
    if name == 'owner' and not bot.ownercheck(ievent, "can merge with owner \
user"):
         return 
    if not users.exist(name):
        ievent.reply("we have no user %s" % name)
        return
    userhost = getwho(bot, nick)
    if not userhost:
        ievent.reply("can't find userhost of %s" % nick)
        return
    username = users.getname(userhost)
    if username:
        ievent.reply('we already have a user with userhost %s (%s)' % \
(userhost, username))
        return
    result = 0
    try:
        result = users.merge(name, userhost)
    except Exception, ex:
        ievent.reply("ERROR: %s" % str(ex))
        return
def handle_report(bot, ievent):
    """ display project report """
    username = users.getname(ievent.userhost)
    if not ievent.rest:
        result = []
        l = getprojects(username)
        for project in l:
            desc = getdesc(username, project) or project
            report = gethourslist(username, project)
            result.append('%s: %s' % (desc, ' '.join(report)))
        l = getcontrib(username)
        for project in l:
            owner = getowner(username, project)
            desc = getdesc(owner, project) or project
            report = gethourslist(owner, project)
            result.append('%s: %s' % (desc, ' '.join(report)))
        if result:
            ievent.reply('', result, dot=True)
        else:
            ievent.reply('no projects found')
    else:
        project = ievent.rest.strip().lower()
        if hasproject(username, project):
            owner = username
        elif hascontrib(username, project):
            owner = getowner(username, project)
        else:
            ievent.reply('no project %s' % project)
            return
        desc = getdesc(owner, project) or project
        report = gethourslist(owner, project)
        ievent.reply('%s: ' % desc, report, dot=True)
Exemple #20
0
def handle_meet(bot, ievent):
    """ user-meet <nick> .. introduce a new user to the bot """
    try:
        nick = ievent.args[0].lower()
    except IndexError:
        ievent.missing('<nick>')
        return
    if users.exist(nick):
        ievent.reply('there is already a user with username %s' % nick)
        return
    userhost = getwho(bot, nick)
    if not userhost:
        ievent.reply("can't find userhost of %s" % nick)
        return
    username = users.getname(userhost)
    if username:
        ievent.reply('we already have a user with userhost %s (%s)' % \
(userhost, username))
        return
    result = 0
    try:
        result = users.add(nick.lower(), [userhost, ], ['USER', ])
    except Exception, ex:
        ievent.reply('ERROR: %s' % str(ex))
        return
Exemple #21
0
def handle_todosettime(bot, ievent):
    """ todo-settime [<channel|name>] <itemnr> <timestring> .. set time \
        on todo item """
    ttime = strtotime(ievent.txt)
    if ttime == None:
        ievent.reply("can't detect time")
        return   
    txt = striptime(ievent.txt)
    try:
        (who, itemnr) = txt.split()
    except ValueError:
        try:
            (itemnr, ) = txt.split()
            who = users.getname(ievent.userhost)
        except ValueError:
            ievent.missing('[<channe|namel>] <itemnr> <timestring>')
            return
    try:
        itemnr = int(itemnr)
    except ValueError:
        ievent.missing('[<channel|name>] <itemnr> <timestring>')
        return
    who = who.lower()
    if not todo.settime(who, itemnr, ttime):
        ievent.reply('no todo %s found for %s' % (itemnr, who))
        return
    ievent.reply('time of todo %s set to %s' % (itemnr, time.ctime(ttime)))
Exemple #22
0
def handle_got(bot, ievent):
    """ got <listofnrs> .. remove items from shoplist """
    if len(ievent.args) == 0:
        ievent.missing('<list of nrs>')
        return
    try:
        nrs = []
        for i in ievent.args:
            nrs.append(int(i))
    except ValueError:
        ievent.reply('%s is not an integer' % i)
        return
    username = users.getname(ievent.userhost)
    try:
        shop = shops[username]
    except KeyError:
        ievent.reply('nothing to shop ;]')
        return
    if not shop:
        ievent.reply("nothing to shop ;]")
        return
    nrs.sort()
    nrs.reverse()
    teller = 0
    for i in range(len(shop) - 1, -1, -1):
        if i in nrs:
            try:
                del shop[i]
                teller += 1
            except IndexError:
                pass
    shops.save()
    ievent.reply('%s shop item(s) deleted' % teller)
Exemple #23
0
def handle_register(bot, ievent):
    if not cfg.get('enable'):
        ievent.reply('register is not enabled')
        return
    if 'OPER' in cfg.get('perms'):
        ievent.reply("can't use OPER permission in register command")
        return
    if not ievent.rest:
        ievent.missing('<username>')
        return
    name = ievent.args[0]
    if users.exist(name):
        ievent.reply('we already have a user with the name %s' % name)
        return
    uh = ievent.userhost
    username = users.getname(uh)
    if username:
        ievent.reply('we already have a user with userhost %s' % uh)
        return
    if users.add(name, [uh, ], perms = cfg.get('perms')):
        throttlestate['level'][uh] = 10
        ievent.reply('%s added to the user database with permission %s' % \
(uh, cfg.get('perms')))
    else:
        ievent.reply('error adding %s (%s) in the user database' % (name, uh))
Exemple #24
0
def handle_powernickdel(bot, ievent):
    global state
    username = users.getname(ievent.userhost)
    try:
        del state['nicks'][username]
        state.save()
        ievent.reply('powernick removed')
    except (ValueError, KeyError):
         ievent.reply('no powernick set')
def greetingcallback(bot, ievent):
    """ do the greeting """
    username = users.getname(ievent.userhost)
    try:
        greetingslist = greetings[username]
        if greetingslist:
            ievent.reply(random.choice(greetingslist))
    except KeyError:
        pass
Exemple #26
0
def handle_shop(bot, ievent):
    """ shop [<item>] .. show shop list or add <item> """
    if len(ievent.args) != 0:
        handle_shop2(bot, ievent)
        return
    shop = []
    username = users.getname(ievent.userhost)
    shop = shops[username]
    sayshop(bot, ievent, shop)
Exemple #27
0
def handle_powernickdel(bot, ievent):
    global state
    username = users.getname(ievent.userhost)
    try:
        del state['nicks'][username]
        state.save()
        ievent.reply('powernick removed')
    except (ValueError, KeyError):
        ievent.reply('no powernick set')
Exemple #28
0
def handle_shop(bot, ievent):
    """ shop [<item>] .. show shop list or add <item> """
    if len(ievent.args) != 0:
        handle_shop2(bot, ievent)
        return
    shop = []
    username = users.getname(ievent.userhost)
    shop = shops[username]
    sayshop(bot, ievent, shop)
Exemple #29
0
def handle_delshop(bot, ievent):
    """ shop-del <username> <listofnrs> .. delete items of someone elses \
        shop list """
    if len(ievent.args) < 2:
        ievent.missing('<username> <listofnrs>')
        return
    else:
        who = ievent.args[0]
    try:
        nrs = []
        for i in ievent.args[1:]:
            nrs.append(int(i))
    except ValueError:
        ievent.reply('%s is not an integer' % i)
        return
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost of %s" % who)
        return
    username = users.getname(ievent.userhost)
    whoname = users.getname(userhost)
    if not whoname:
        ievent.reply("can't find user for %s" % userhost)
        return
    if users.permitted(userhost, username, 'shop'):
        try:
            shop = shops[whoname]
        except KeyError:
            ievent.reply('nothing to shop ;]')
            return
        nrs.sort()
        nrs.reverse()
        for i in range(len(shop)-1, -1 , -1):
            if i in nrs:
                try:
                    del shop[i]
                except IndexError:
                    pass
        shops.save()
        ievent.reply('shop item deleted')
    else:
        ievent.reply("%s does not share shopping list with %s" % (who, \
username))
Exemple #30
0
 def handle_close(self, bot, ievent):
     if len(ievent.args) < 3:
         ievent.missing('<bug id> <action> <message>')
         return
     try:
         status = self.close(ievent.args[0], users.getname(ievent.userhost), 
             ' '.join(ievent.args[2:]), ievent.args[1])
         ievent.reply('ok')
     except AssertionError, e:
         ievent.reply('error: %s' % e)
Exemple #31
0
def handle_delshop(bot, ievent):
    """ shop-del <username> <listofnrs> .. delete items of someone elses \
        shop list """
    if len(ievent.args) < 2:
        ievent.missing('<username> <listofnrs>')
        return
    else:
        who = ievent.args[0]
    try:
        nrs = []
        for i in ievent.args[1:]:
            nrs.append(int(i))
    except ValueError:
        ievent.reply('%s is not an integer' % i)
        return
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost of %s" % who)
        return
    username = users.getname(ievent.userhost)
    whoname = users.getname(userhost)
    if not whoname:
        ievent.reply("can't find user for %s" % userhost)
        return
    if users.permitted(userhost, username, 'shop'):
        try:
            shop = shops[whoname]
        except KeyError:
            ievent.reply('nothing to shop ;]')
            return
        nrs.sort()
        nrs.reverse()
        for i in range(len(shop) - 1, -1, -1):
            if i in nrs:
                try:
                    del shop[i]
                except IndexError:
                    pass
        shops.save()
        ievent.reply('shop item deleted')
    else:
        ievent.reply("%s does not share shopping list with %s" % (who, \
username))
 def handle_close(self, bot, ievent):
     if len(ievent.args) < 3:
         ievent.missing('<bug id> <action> <message>')
         return
     try:
         status = self.close(ievent.args[0], users.getname(ievent.userhost),
                             ' '.join(ievent.args[2:]), ievent.args[1])
         ievent.reply('ok')
     except AssertionError, e:
         ievent.reply('error: %s' % e)
def handle_bddel(bot, ievent):
    """ bd-del .. delete birthday """
    name = users.getname(ievent.userhost)
    result = 0
    s = create_session()
    bd = s.query(Birthday).filter(Birthday.name==name).first()
    if not bd:
        ievent.reply('no birthday known for %s (%s)' % (ievent.nick, name))
    else:
        s.delete(bd)
        ievent.reply('birthday removed')
def handle_greetingadd(bot, ievent):
    """ add greetings txt """
    if not greetings:
        ievent.reply('the greet plugin is not properly initialised')
    if not ievent.rest:
        ievent.missing('<txt>')
        return
    username = users.getname(ievent.userhost)
    greetings.add(username, ievent.rest)
    greetings.save()
    ievent.reply('greeting message added')
def handle_greetinglist(bot, ievent):
    """ list the greetings list of an user """
    if not greetings:
        ievent.reply('the greet plugin is not properly initialised')
        return
    username = users.getname(ievent.userhost)
    result = greetings.get(username)
    if result:
        ievent.reply("greetings: ", result, nr=0)
    else:
        ievent.reply('no greetings set')
Exemple #36
0
def handle_shop2(bot, ievent):
    """ add items to shop list """
    if not ievent.rest:
        ievent.missing('<shopitem>')
        return
    else:
        what = ievent.rest
    username = users.getname(ievent.userhost)
    shops[username] = what
    shops.save()
    ievent.reply('shop item added')
Exemple #37
0
def handle_shop2(bot, ievent):
    """ add items to shop list """
    if not ievent.rest:
        ievent.missing('<shopitem>')
        return
    else:
        what = ievent.rest
    username = users.getname(ievent.userhost)
    shops[username] = what
    shops.save()
    ievent.reply('shop item added')
Exemple #38
0
def handle_powernick(bot, ievent):
    global state
    nick = ievent.nick
    if not partyline.is_on(nick):
        ievent.reply('%s is not joined on the partylist .. make a dcc chat\
 connection to the bot' % nick)
        return
    username = users.getname(ievent.userhost)
    state['nicks'][username] = nick
    state.save()
    ievent.reply('powernick set to %s' % nick)
Exemple #39
0
def handle_powernick(bot, ievent):
    global state
    nick = ievent.nick
    if not partyline.is_on(nick):
        ievent.reply('%s is not joined on the partylist .. make a dcc chat\
 connection to the bot' % nick)
        return
    username = users.getname(ievent.userhost)
    state['nicks'][username] = nick
    state.save()
    ievent.reply('powernick set to %s' % nick)
Exemple #40
0
def handle_getshop(bot, ievent):
    """ shop-get <name> .. get items of someone elses shop list """
    if not ievent.rest:
        ievent.missing('<username>')
        return
    who = ievent.rest
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost of %s" % who)
        return
    username = users.getname(ievent.userhost)
    whoname = users.getname(userhost)
    if not whoname:
        ievent.reply("can't find user for %s" % userhost)
        return
    if users.permitted(userhost, username, 'shop'):
        shop = shops[whoname]
        sayshop(bot, ievent, shop)
    else:
        ievent.reply("%s does not share shopping list with %s" % (who, \
username))
Exemple #41
0
def handle_perms(bot, ievent):
    """ user-perms .. get permission of the user given the command """
    if ievent.rest:
        ievent.reply("use getperms to get the permissions of somebody else")
        return
    name = users.getname(ievent.userhost)
    if not name:
         ievent.reply("can't find username for %s" % ievent.userhost)
         return
    perms = users.getuserperms(name)
    if perms:
        ievent.reply("you have permissions: ", perms, dot=True)
Exemple #42
0
def handle_delemail(bot, ievent):
    """ user-delemail .. reset email of user giving the command """
    name = users.getname(ievent.userhost)
    if not name:
        ievent.reply("can't find user for %s" % ievent.userhost)
        return
    result = 0
    try:
        result = users.delallemail(name)
    except Exception, ex:
        ievent.reply("ERROR: %s" % str(ex))
        return
Exemple #43
0
def handle_getshop(bot, ievent):
    """ shop-get <name> .. get items of someone elses shop list """
    if not ievent.rest:
        ievent.missing('<username>')
        return
    who = ievent.rest
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost of %s" % who)
        return
    username = users.getname(ievent.userhost)
    whoname = users.getname(userhost)
    if not whoname:
        ievent.reply("can't find user for %s" % userhost)
        return
    if users.permitted(userhost, username, 'shop'):
        shop = shops[whoname]
        sayshop(bot, ievent, shop)
    else:
        ievent.reply("%s does not share shopping list with %s" % (who, \
username))
Exemple #44
0
def handle_gettodo(bot, ievent):
    """ todo-get <nick> .. get todo of another user """
    try:
        who = ievent.args[0]
    except IndexError:
        ievent.missing('<nick>')
        return
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost for %s" % who)
        return
    whouser = users.getname(userhost)
    if not whouser:
        ievent.reply("can't find user for %s" % userhost)
        return
    name = users.getname(ievent.userhost)
    if not users.permitted(userhost, name, 'todo'):
        ievent.reply("%s doesn't permit todo sharing for %s " % (who, name))
        return
    todoos = todo.get(whouser)
    saytodo(bot, ievent, todoos)
Exemple #45
0
def handle_gettodo(bot, ievent):
    """ todo-get <nick> .. get todo of another user """
    try:
        who = ievent.args[0]
    except IndexError:
        ievent.missing('<nick>')
        return
    userhost = getwho(bot, who)
    if not userhost:
        ievent.reply("can't find userhost for %s" % who)
        return
    whouser = users.getname(userhost)
    if not whouser:
        ievent.reply("can't find user for %s" % userhost)
        return
    name = users.getname(ievent.userhost)
    if not users.permitted(userhost, name, 'todo'):
        ievent.reply("%s doesn't permit todo sharing for %s " % (who, name))
        return
    todoos = todo.get(whouser)
    saytodo(bot, ievent, todoos)
Exemple #46
0
def handle_todo(bot, ievent):
    """ todo [<item>] .. show todo's or set todo item .. a time/date can be \
given"""
    if len(ievent.args) > 0:
        handle_todo2(bot, ievent)
        return
    name = users.getname(ievent.userhost)
    try:
        todoos = todo.get(name)
    except KeyError:
        ievent.reply('i dont have todo info for %s' % user.name)
        return
    saytodo(bot, ievent, todoos)
Exemple #47
0
def handle_todo(bot, ievent):
    """ todo [<item>] .. show todo's or set todo item .. a time/date can be \
given"""
    if len(ievent.args) > 0:
        handle_todo2(bot, ievent)
        return
    name = users.getname(ievent.userhost)
    try:
        todoos = todo.get(name)
    except KeyError:
        ievent.reply('i dont have todo info for %s' % user.name)
        return
    saytodo(bot, ievent, todoos)