コード例 #1
0
ファイル: static.py プロジェクト: keab42/lrrbot
def generate_hook():
    global command_expression
    if command_expression is not None:
        bot.remove_command(command_expression)
    static_response.__doc__ = generate_docstring()
    command_expression = generate_expression()
    bot.add_command(command_expression, static_response)
コード例 #2
0
ファイル: static.py プロジェクト: MatthewCox/lrrbot
def generate_hook():
	global command_expression
	if command_expression is not None:
		bot.remove_command(command_expression)
	static_response.__doc__ = generate_docstring()
	command_expression = generate_expression()
	bot.add_command(command_expression, static_response)
コード例 #3
0
def modify_commands(commands):
    bot.remove_command(generate_expression(storage.data["responses"]))
    storage.data["responses"] = {k.lower(): v for k, v in commands.items()}
    storage.save()
    static_response.__doc__ = generate_docstring()
    bot.add_command(generate_expression(storage.data["responses"]),
                    static_response)
コード例 #4
0
def modify_explanations(commands):
    bot.remove_command("explain " +
                       generate_expression(storage.data["explanations"]))
    storage.data["explanations"] = {k.lower(): v for k, v in commands.items()}
    storage.save()
    explain_response.__doc__ = generate_explain_docstring()
    bot.add_command(
        "explain " + generate_expression(storage.data["explanations"]),
        explain_response)
コード例 #5
0
ファイル: stats.py プロジェクト: DarkMatterz/lrrbot
		if game is None:
			conn.privmsg(respond_to, "Not currently playing any game")
			return
	count = game.get("stats", {}).get(stat, 0)
	countT = sum(game.get("stats", {}).get(stat, 0) for game in storage.data["games"].values())
	stat_details = storage.data["stats"][stat]
	display = stat_details.get("singular", stat) if count == 1 else stat_details.get("plural", stat + "s")
	if with_emote and stat_details.get("emote"):
		emote = stat_details["emote"] + " "
	else:
		emote = ""
	conn.privmsg(respond_to, "%s%d %s for %s" % (emote, count, display, game_name(game)))
	if countT == 1000:
		conn.privmsg(respond_to, "Watch and pray for another %d %s!" % (countT, display))

@utils.throttle(params=[4])
def printtotal(lrrbot, conn, event, respond_to, stat):
	count = sum(game.get("stats", {}).get(stat, 0) for game in storage.data["games"].values())
	display = storage.data["stats"][stat]
	display = display.get("singular", stat) if count == 1 else display.get("plural", stat + "s")
	conn.privmsg(respond_to, "%d total %s" % (count, display))

re_stats = "|".join(storage.data["stats"])

bot.add_command("(%s)" % re_stats, increment)
bot.add_command("(%s) add( \d+)?" % re_stats, add)
bot.add_command("(%s) remove( \d+)?" % re_stats, remove)
bot.add_command("(%s) set (\d+)" % re_stats, stat_set)
bot.add_command("(%s)count" % re_stats, stat_print)
bot.add_command("total(%s)" % re_stats, printtotal)
コード例 #6
0
        response = random.choice(response)
    conn.privmsg(respond_to, response)


def modify_commands(commands):
    bot.remove_command(generate_expression(storage.data["responses"]))
    storage.data["responses"] = {k.lower(): v for k, v in commands.items()}
    storage.save()
    static_response.__doc__ = generate_docstring()
    bot.add_command(generate_expression(storage.data["responses"]),
                    static_response)


def modify_explanations(commands):
    bot.remove_command("explain " +
                       generate_expression(storage.data["explanations"]))
    storage.data["explanations"] = {k.lower(): v for k, v in commands.items()}
    storage.save()
    explain_response.__doc__ = generate_explain_docstring()
    bot.add_command(
        "explain " + generate_expression(storage.data["explanations"]),
        explain_response)


static_response.__doc__ = generate_docstring()
bot.add_command(generate_expression(storage.data["responses"]),
                static_response)
explain_response.__doc__ = generate_explain_docstring()
bot.add_command("explain " + generate_expression(storage.data["explanations"]),
                explain_response)
コード例 #7
0
                 "%s%d %s for %s" % (emote, count, display, game_name(game)))
    if countT == 1000:
        conn.privmsg(respond_to,
                     "Watch and pray for another %d %s!" % (countT, display))
    if countT == 2500:
        conn.privmsg(
            respond_to,
            "For hitting this milestone here's some code drop, Fez: 63BT5-GQ72Z-6L068 Mark of the Ninja: C03YW-YX0CA-IYC85 FTL: 5539N-PAREC-J4YGM Bastion: TE4M2-A5V64-BITNV"
            % (countT, display))


@utils.throttle(params=[4])
def printtotal(lrrbot, conn, event, respond_to, stat):
    count = sum(
        game.get("stats", {}).get(stat, 0)
        for game in storage.data["games"].values())
    display = storage.data["stats"][stat]
    display = display.get("singular", stat) if count == 1 else display.get(
        "plural", stat + "s")
    conn.privmsg(respond_to, "%d total %s" % (count, display))


re_stats = "|".join(storage.data["stats"])

bot.add_command("(%s)" % re_stats, increment)
bot.add_command("(%s) add( \d+)?" % re_stats, add)
bot.add_command("(%s) remove( \d+)?" % re_stats, remove)
bot.add_command("(%s) set (\d+)" % re_stats, stat_set)
bot.add_command("(%s)count" % re_stats, stat_print)
bot.add_command("total(%s)" % re_stats, printtotal)
コード例 #8
0
ファイル: static.py プロジェクト: korvys/lrrbot
def modify_explanations(commands):
    bot.remove_command("explain " + generate_expression(storage.data["explanations"]))
    storage.data["explanations"] = {k.lower(): v for k,v in commands.items()}
    storage.save()
    explain_response.__doc__ = generate_explain_docstring()
    bot.add_command("explain " + generate_expression(storage.data["explanations"]), explain_response)
コード例 #9
0
ファイル: static.py プロジェクト: korvys/lrrbot
def modify_commands(commands):
    bot.remove_command(generate_expression(storage.data["responses"]))
    storage.data["responses"] = {k.lower(): v for k,v in commands.items()}
    storage.save()
    static_response.__doc__ = generate_docstring()
    bot.add_command(generate_expression(storage.data["responses"]), static_response)
コード例 #10
0
ファイル: static.py プロジェクト: korvys/lrrbot
	response = storage.data["responses"][command.lower()]
	if isinstance(response, (tuple, list)):
		response = random.choice(response)
	conn.privmsg(respond_to, response)

@utils.throttle(5, params=[4])
def explain_response(lrrbot, conn, event, respond_to, command):
	response = storage.data["explanations"][command.lower()]
	if isinstance(response, (tuple, list)):
		response = random.choice(response)
	conn.privmsg(respond_to, response)

def modify_commands(commands):
    bot.remove_command(generate_expression(storage.data["responses"]))
    storage.data["responses"] = {k.lower(): v for k,v in commands.items()}
    storage.save()
    static_response.__doc__ = generate_docstring()
    bot.add_command(generate_expression(storage.data["responses"]), static_response)

def modify_explanations(commands):
    bot.remove_command("explain " + generate_expression(storage.data["explanations"]))
    storage.data["explanations"] = {k.lower(): v for k,v in commands.items()}
    storage.save()
    explain_response.__doc__ = generate_explain_docstring()
    bot.add_command("explain " + generate_expression(storage.data["explanations"]), explain_response)

static_response.__doc__ = generate_docstring()
bot.add_command(generate_expression(storage.data["responses"]), static_response)
explain_response.__doc__ = generate_explain_docstring()
bot.add_command("explain " + generate_expression(storage.data["explanations"]), explain_response)