<commit_before>import flask.json
import socket
import login

def send_bot_command(command, param, timeout=5):
	"""
	Send a message to the bot, and return the response

	Raises socket.timeout in the event of a timeout
	"""
	# Call load_session separately instead of @with_session
	# so we can turn off all the flags that use botinteract calls
	# to avoid infinite recursion
	session = login.load_session(include_header=False)
	conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
	conn.settimeout(timeout)
	conn.connect("../lrrbot.sock")
	data = {
		"command": command,
		"param": param,
		"user": session['user'],
	}
	conn.send((flask.json.dumps(data) + "\n").encode())
	buf = b""
	while b"\n" not in buf:
		buf += conn.recv(1024)
	return flask.json.loads(buf.decode())

def get_current_game():
	return send_bot_command("current_game", None)

def get_data(key):
	return send_bot_command("get_data", {
		'key': key,
	})

def set_data(key, value):
	"""
	Send a message to the bot, to update its storage.

	Will return after the data.json has been updated.
	"""
	send_bot_command("set_data", {
		'key': key,
		'value': value,
	})

def modify_commands(data):
	"""
	Send a message to the bot, to replace the static command responses.
	"""
	send_bot_command("modify_commands", data)

def modify_explanations(data):
	"""
	Send a message to the bot, to replace the static command responses.
	"""
	send_bot_command("modify_explanations", data)

def modify_spam_rules(data):
	"""
	Send a message to the bot, to replace the static command responses.
	"""
	send_bot_command("modify_spam_rules", data)

def get_commands():
	return send_bot_command("get_commands", None)

def get_header_info():
	return send_bot_command("get_header_info", None)<commit_msg>Fix some copypasted docstrings<commit_after>import flask.json
import socket
import login

def send_bot_command(command, param, timeout=5):
	"""
	Send a message to the bot, and return the response

	Raises socket.timeout in the event of a timeout
	"""
	# Call load_session separately instead of @with_session
	# so we can turn off all the flags that use botinteract calls
	# to avoid infinite recursion
	session = login.load_session(include_header=False)
	conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
	conn.settimeout(timeout)
	conn.connect("../lrrbot.sock")
	data = {
		"command": command,
		"param": param,
		"user": session['user'],
	}
	conn.send((flask.json.dumps(data) + "\n").encode())
	buf = b""
	while b"\n" not in buf:
		buf += conn.recv(1024)
	return flask.json.loads(buf.decode())

def get_current_game():
	return send_bot_command("current_game", None)

def get_data(key):
	return send_bot_command("get_data", {
		'key': key,
	})

def set_data(key, value):
	"""
	Send a message to the bot, to update its storage.

	Will return after the data.json has been updated.
	"""
	send_bot_command("set_data", {
		'key': key,
		'value': value,
	})

def modify_commands(data):
	"""
	Send a message to the bot, to replace the static command responses.
	"""
	send_bot_command("modify_commands", data)

def modify_explanations(data):
	"""
	Send a message to the bot, to replace the explain responses.
	"""
	send_bot_command("modify_explanations", data)

def modify_spam_rules(data):
	"""
	Send a message to the bot, to replace the spam rules.
	"""
	send_bot_command("modify_spam_rules", data)

def get_commands():
	return send_bot_command("get_commands", None)

def get_header_info():
	return send_bot_command("get_header_info", None)
{'fraction_non_alphanumeric': 0.12327981651376146, 'fraction_numerical': 0.0028669724770642203, 'mean_word_length': 5.01551724137931, 'pattern_counts': {'":': 6, '<': 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': '1413203', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1173, 'n_words': 344}