コード例 #1
0
ファイル: crazyphrases.py プロジェクト: JamieHouston/marvin
def check_phrases(bot_input, bot_output):
    for user, phrase in user_phrases.items():
        if phrase == textutils.sanitize_message(bot_input.message):
            if user == bot_input.nick:
                user_points[user] += 1
                storage.set_hash_value(list_name, bot_input.nick, user_points[user])
                user_info = bot_output.get_user_by_name(user)
                bot_output.private_message(
                    str(user_info["id"]), "You got a point.  Current score for you is: %s" % user_points[user]
                )
            else:
                bot_output.say("Woot!  Phrase that pays!")
                bot_output.say("%s had the phrase: %s" % (user, phrase))
                bot_output.say("Good job " + bot_input.nick)
                user_points[user] = user_points[bot_input.nick] + 1
                storage.set_hash_value(list_name, bot_input.nick, user_points[user])
コード例 #2
0
ファイル: trivia.py プロジェクト: JamieHouston/marvin
def trivia(bot_input, bot_output):
    if "reset" in bot_input.input_string:
        storage.set_hash_value(list_name, bot_input.nick, 0)
        user_points[bot_input.nick] = 0
        bot_output.say("{0}'s score is now 0".format(bot_input.nick))
    elif "reload" in bot_input.input_string:
        load_questions()
    elif "score" in bot_input.input_string:
        get_points(bot_input, bot_output)
    elif "categories" in bot_input.input_string:
        bot_output.say(', '.join(list(question_list.keys())))
    elif bot_input.input_string in question_list:
        new_question(bot_input.input_string)
    else:
        if 'question' not in current_trivia:
            new_question()
        else:
            bot_output.say("Use '.answer' to get the answer and a new question\nUse .trivia categories to see all categories\nUse .trivia <category name> to get questions from a certain category\nUse .trivia points to see current score\nUse birth control to prevent more wrong answers\n\nCurrent question:")
        bot_output.say('Category: %(category)s\n%(question)s?' % current_trivia)
コード例 #3
0
ファイル: trivia.py プロジェクト: JamieHouston/marvin
def add_point(nick, points):
    current_score = int(storage.get_hash_value(list_name, nick) or 0)
    if points > 0:
        points = points * current_trivia['multiplier']
    user_points[nick] = current_score + points
    storage.set_hash_value(list_name, nick, user_points[nick])
コード例 #4
0
ファイル: userinfo.py プロジェクト: JamieHouston/marvin
def set_team_info(team_name, username, role):
    storage.set_hash_value(get_team_key(team_name), username, role)
コード例 #5
0
ファイル: userinfo.py プロジェクト: JamieHouston/marvin
def set_user_info(username, key, value):
    storage.set_hash_value(get_user_key(username), key, value)