<commit_before>from lrrbot import bot
from config import config
import storage
import random
import utils
import re

def generate_docstring():
	inverse_responses = {}
	for command, response in storage.data["responses"].items():
		if isinstance(response, (tuple, list)):
			response = tuple(response)
		inverse_responses.setdefault(response, [])
		inverse_responses[response] += [command]
	def generator():
		for response, command in inverse_responses.items():
			fragment = ""
			if isinstance(command, list):
				for cmd in command:
					fragment += "Command: %s%s\n" % (config["commandprefix"], cmd)
			else:
				fragment += "Command: %s%s\n" % (config["commandprefix"], cmd)
			fragment += "Throttled: 5\n"
			fragment += "\n"
			response = response if isinstance(response, str) else random.choice(response)
			fragment += response + "\n"
			yield fragment
	return "\n--command\n".join(generator())

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

def modify_commands(commands):
    bot.remove_command("(%s)" % "|".join(re.escape(c) for c in storage.data["responses"]))
    storage.data["responses"] = commands
    storage.save()
    static_response.__doc__ = generate_docstring()
    bot.add_command("(%s)" % "|".join(re.escape(c) for c in storage.data["responses"]), static_response)

static_response.__doc__ = generate_docstring()
bot.add_command("(%s)" % "|".join(re.escape(c) for c in storage.data["responses"]), static_response)<commit_msg>static commands: convert to lower case<commit_after>from lrrbot import bot
from config import config
import storage
import random
import utils
import re

def generate_docstring():
	inverse_responses = {}
	for command, response in storage.data["responses"].items():
		if isinstance(response, (tuple, list)):
			response = tuple(response)
		inverse_responses.setdefault(response, [])
		inverse_responses[response] += [command]
	def generator():
		for response, command in inverse_responses.items():
			fragment = ""
			if isinstance(command, list):
				for cmd in command:
					fragment += "Command: %s%s\n" % (config["commandprefix"], cmd)
			else:
				fragment += "Command: %s%s\n" % (config["commandprefix"], cmd)
			fragment += "Throttled: 5\n"
			fragment += "\n"
			response = response if isinstance(response, str) else random.choice(response)
			fragment += response + "\n"
			yield fragment
	return "\n--command\n".join(generator())

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

def modify_commands(commands):
    bot.remove_command("(%s)" % "|".join(re.escape(c) for c in storage.data["responses"]))
    storage.data["responses"] = dict(map(lambda c: (c[0].lower(), c[1]), commands.items()))
    storage.save()
    static_response.__doc__ = generate_docstring()
    bot.add_command("(%s)" % "|".join(re.escape(c) for c in storage.data["responses"]), static_response)

static_response.__doc__ = generate_docstring()
bot.add_command("(%s)" % "|".join(re.escape(c) for c in storage.data["responses"]), static_response)
{'fraction_non_alphanumeric': 0.1562683931724544, 'fraction_numerical': 0.002354326074161271, 'mean_word_length': 5.282809611829944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2802669', 'n_tokens_mistral': 1132, 'n_tokens_neox': 1059, 'n_words': 258}