From 7a564b835b6bc4ae7321a8ce74a7c891fd451701 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Tue, 26 Jan 2021 00:07:24 -0500 Subject: [PATCH] Update style according to Flake8 --- tallbot.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tallbot.py b/tallbot.py index fba1c16..1b184f2 100755 --- a/tallbot.py +++ b/tallbot.py @@ -2,6 +2,7 @@ # tall.bot - a simple Discord Wikipedia bot # Armaan Bhojwani 2021 + import logging import sqlite3 import sys @@ -9,9 +10,11 @@ import time import wikipedia import discord + def wiki_sum(search, sen, pid): try: - logging.info(str(pid) + " | " + str(int(time.time())) + " | " + str(search)) + logging.info(str(pid) + " | " + str(int(time.time())) + " | " + + str(search)) log_query(search, pid) return " " + wikipedia.summary(search, sentences=sen, @@ -20,6 +23,7 @@ def wiki_sum(search, sen, pid): logging.debug(str(pid) + " | " + str(search) + " | " + str(e)) return str(e) + def create_query(inp): key1 = ["What", "what", "who", "Who", "what's", "What's", "whats", "Whats", "Whatsa", "whatsa"] @@ -36,6 +40,7 @@ def create_query(inp): return " ".join(x) + def tell_more(inp, pid): def find_query(inp): key1 = ["Tell me more", "tell me more"] @@ -57,6 +62,7 @@ def tell_more(inp, pid): else: return False + def prep_database(): c.execute("""CREATE TABLE IF NOT EXISTS queries( time INTEGER, @@ -64,6 +70,7 @@ def prep_database(): query TEXT)""") conn.commit() + def log_query(search, pid): c.execute("DELETE FROM queries WHERE pid = (?)", (str(pid),)) c.execute("""INSERT INTO queries @@ -71,6 +78,7 @@ def log_query(search, pid): (int(time.time()), str(pid), str(search))) conn.commit() + class TallBot(discord.Client): async def on_ready(self): logging.info('Logged in as ', self.user) @@ -86,10 +94,12 @@ class TallBot(discord.Client): elif more_info: await message.channel.send(wiki_sum(more_info, 6, message.author)) + def main(): prep_database() TallBot().run(sys.argv[1]) + if __name__ == "__main__": conn = sqlite3.connect("queries.db") c = conn.cursor() -- 2.39.2