示例#1
0
文件: update.py 项目: jakinov/uoflol
 def get(self):
     userList = User.all()
     for user in userList:
         d = call_api(id=user.internalName, api="LOL", ext="USER")
         if d is None:
             user.marked = True
             break
         user.internalName, user.displayName, user.iconID = d["data"]["internalName"], d["data"]["name"], d["data"]["icon"]
         user.put()
     get_user_list(update=True)
示例#2
0
def record_welp(bot, trigger):
    # TODO: record winner at time of welp
    if bot.memory.contains('welpcall_active') and bot.memory['welpcall_active']:
        welp_list = bot.memory['welpcall_list']
        nick = trigger.nick
        if nick not in welp_list:
            welp_list.append(nick)
        
        if welp_list == utils.get_user_list(bot, '#testchannelpleaseignore'):
            _end_welpcall(bot)
示例#3
0
def record_welp(bot, trigger):
    # TODO: record winner at time of welp
    if bot.memory.contains(
            'welpcall_active') and bot.memory['welpcall_active']:
        welp_list = bot.memory['welpcall_list']
        nick = trigger.nick
        if nick not in welp_list:
            welp_list.append(nick)

        if welp_list == utils.get_user_list(bot, '#testchannelpleaseignore'):
            _end_welpcall(bot)
示例#4
0
def _end_welpcall(bot):
    bot.memory['welpcall_active'] = False
    users = utils.get_user_list(bot, '#testchannelpleaseignore')

    if len(bot.memory['welpcall_list']):
        winner = bot.memory['welpcall_list'][0]
        missed = set(users) - set(bot.memory['welpcall_list'])
    else:
        winner = None
        missed = users

    if '#testchannelpleaseignore' in bot.channels:
        bot.msg('#testchannelpleaseignore', 'welpcall complete.')
        bot.msg('#testchannelpleaseignore', 'Winner: ' + (winner or 'no one'))
        bot.msg('#testchannelpleaseignore', 'Failed to welp: ' + ', '.join(missed))

    if winner:
        win_count = bot.db.get_nick_value(winner, 'welpcall_wins') or 0
        bot.db.set_nick_value(winner, 'welpcall_wins', win_count + 1)
    if missed:
        for nick in missed:
            loss_count = bot.db.get_nick_value(nick, 'welpcall_misses') or 0
            bot.db.set_nick_value(nick, 'welpcall_misses', loss_count + 1)
示例#5
0
def _end_welpcall(bot):
    bot.memory['welpcall_active'] = False
    users = utils.get_user_list(bot, '#testchannelpleaseignore')

    if len(bot.memory['welpcall_list']):
        winner = bot.memory['welpcall_list'][0]
        missed = set(users) - set(bot.memory['welpcall_list'])
    else:
        winner = None
        missed = users

    if '#testchannelpleaseignore' in bot.channels:
        bot.msg('#testchannelpleaseignore', 'welpcall complete.')
        bot.msg('#testchannelpleaseignore', 'Winner: ' + (winner or 'no one'))
        bot.msg('#testchannelpleaseignore',
                'Failed to welp: ' + ', '.join(missed))

    if winner:
        win_count = bot.db.get_nick_value(winner, 'welpcall_wins') or 0
        bot.db.set_nick_value(winner, 'welpcall_wins', win_count + 1)
    if missed:
        for nick in missed:
            loss_count = bot.db.get_nick_value(nick, 'welpcall_misses') or 0
            bot.db.set_nick_value(nick, 'welpcall_misses', loss_count + 1)
示例#6
0
 def dehydrate_friends(self, bundle):
     return get_user_list(bundle.obj.relationships.friends())
示例#7
0
 def dehydrate_following(self, bundle):
     return get_user_list(bundle.obj.relationships.following())