<commit_before>import os, sqlite3, json, random, markovify, re, time
from colorama import init, Fore, Style
from aiotg import Bot


START_TIME = time.time()

# Count the number of handled requests via decorator
REQNUM = 0
def request(fn):
	def wrapper(*args, **kwargs):
		global REQNUM
		REQNUM += 1
		return fn(*args, **kwargs)
	return wrapper


with open("rp_data.txt", "r") as f:
    text = f.read()

text_model = markovify.NewlineText(text, state_size=2)
del text

vs = "V0.2"

CACHE_DIR = 'cache/'
RES_FOLDER = 'res/'

con = sqlite3.connect('wolfe.db')

bot = Bot(os.environ["API_TOKEN"])

basekeyboard = {'keyboard': [[{'text': '💡 Suggest'},{'text': '⭐️ Vote'}],[{'text': '⚠️ Report'},{'text': '🐾 Credits'}]], 'one_time_keyboard': True, 'resize_keyboard': True}

@bot.command(r"^\/(help|start)(\s*$|@WolfeLegacyBB?ot)") # Don't match commands aimed at other bots
async def welcome(chat, match):
	await chat.send_sticker(sticker="BQADAwADAgADZUASA3hbI2mGeTbkAg")
	await chat.send_text("\
		Hello, welcome to WolfeBot. This bot is not completely stable yet, so don't be alarmed if it stops working for a bit!\n\n\
		For further info please visit the channel @WolfeBotNews\n\
		Bug reports and feature requests ==> https://github.com/TNTINC/WolfeBot/issues \n\
		<em>If it goes absolutely haywire, throw a line at</em> @icefla", 
	parse_mode="HTML")
	return

@bot.command(r'^\/debugdump')
async def dump(chat, match):
	dbsize = len(con.execute("SELECT id FROM media").fetchall())
	db_amount_not_approved = len(
		con.execute("SELECT id FROM media WHERE approved = 0")
		.fetchall()
	)
	
	my_id = (await bot.get_me())["id"]

	# uptime
	m, s = divmod(time.time() - START_TIME, 60)
	h, m = divmod(m, 60)
	uptime_string = "%d:%02d:%02d" % (h, m, s)

	dump = \
	"""
	-- {time} --
	Wolfe {vs}
	{dbsize} images in database, {db_amount_not_approved} not approved.
	My id is {my_id}. Uptime is: {uptime}.
	{reqnum} requests handled.
	""".format(
		time = time.strftime("%a, %d %b %Y %H:%M:%S UTC"),
		vs = vs,
		dbsize = dbsize,
		db_amount_not_approved = db_amount_not_approved,
		my_id = my_id,
		uptime = uptime_string,
		reqnum = REQNUM 
	)
	return chat.reply(dump)

@bot.command(r'^fml')
def weather(chat, match):
	return chat.reply('*fucks your life*')

# Roleplay (owo)
@bot.command(r'\*(.+)\*')
@request
def roleplay(chat, match):
	return chat.reply("*%s*" % text_model.make_short_sentence(200, tries=200).strip(" .*"))

# Respond to OwO appropriately
@bot.command(r'^OwO')
@request
def owo(chat, match):<commit_msg>hotfix: disabled markov chain roleplaying thing<commit_after>import os, sqlite3, json, random, markovify, re, time
from colorama import init, Fore, Style
from aiotg import Bot


START_TIME = time.time()

# Count the number of handled requests via decorator
REQNUM = 0
def request(fn):
	def wrapper(*args, **kwargs):
		global REQNUM
		REQNUM += 1
		return fn(*args, **kwargs)
	return wrapper


with open("rp_data.txt", "r") as f:
    text = f.read()

text_model = markovify.NewlineText(text, state_size=2)
del text

vs = "V0.2"

CACHE_DIR = 'cache/'
RES_FOLDER = 'res/'

con = sqlite3.connect('wolfe.db')

bot = Bot(os.environ["API_TOKEN"])

basekeyboard = {'keyboard': [[{'text': '💡 Suggest'},{'text': '⭐️ Vote'}],[{'text': '⚠️ Report'},{'text': '🐾 Credits'}]], 'one_time_keyboard': True, 'resize_keyboard': True}

@bot.command(r"^\/(help|start)(\s*$|@WolfeLegacyBB?ot)") # Don't match commands aimed at other bots
async def welcome(chat, match):
	await chat.send_sticker(sticker="BQADAwADAgADZUASA3hbI2mGeTbkAg")
	await chat.send_text("\
		Hello, welcome to WolfeBot. This bot is not completely stable yet, so don't be alarmed if it stops working for a bit!\n\n\
		For further info please visit the channel @WolfeBotNews\n\
		Bug reports and feature requests ==> https://github.com/TNTINC/WolfeBot/issues \n\
		<em>If it goes absolutely haywire, throw a line at</em> @icefla", 
	parse_mode="HTML")
	return

@bot.command(r'^\/debugdump')
async def dump(chat, match):
	dbsize = len(con.execute("SELECT id FROM media").fetchall())
	db_amount_not_approved = len(
		con.execute("SELECT id FROM media WHERE approved = 0")
		.fetchall()
	)
	
	my_id = (await bot.get_me())["id"]

	# uptime
	m, s = divmod(time.time() - START_TIME, 60)
	h, m = divmod(m, 60)
	uptime_string = "%d:%02d:%02d" % (h, m, s)

	dump = \
	"""
	-- {time} --
	Wolfe {vs}
	{dbsize} images in database, {db_amount_not_approved} not approved.
	My id is {my_id}. Uptime is: {uptime}.
	{reqnum} requests handled.
	""".format(
		time = time.strftime("%a, %d %b %Y %H:%M:%S UTC"),
		vs = vs,
		dbsize = dbsize,
		db_amount_not_approved = db_amount_not_approved,
		my_id = my_id,
		uptime = uptime_string,
		reqnum = REQNUM 
	)
	return chat.reply(dump)

@bot.command(r'^fml')
def weather(chat, match):
	return chat.reply('*fucks your life*')

# Roleplay (owo)
@bot.command(r'\*(.+)\*')
@request
def roleplay(chat, match):
	pass 
	#return chat.reply("*%s*" % text_model.make_short_sentence(200, tries=200).strip(" .*"))

# Respond to OwO appropriately
@bot.command(r'^OwO')
@request
def owo(chat, match):
{'fraction_non_alphanumeric': 0.16738873572272547, 'fraction_numerical': 0.009452540370224497, 'mean_word_length': 4.649610678531702, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '266663', 'n_tokens_mistral': 2070, 'n_tokens_neox': 1963, 'n_words': 515}