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_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 #6
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 #7
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 #8
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 #9
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 #10
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))