summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArmaan Bhojwani <me@armaanb.net>2021-01-26 00:07:24 -0500
committerArmaan Bhojwani <me@armaanb.net>2021-01-26 00:07:24 -0500
commit7a564b835b6bc4ae7321a8ce74a7c891fd451701 (patch)
treed987af01e5896c569d1f6b5ab3015463994eb793
parentda004a969e475c8a39eb9c652b0706b5b4a92a08 (diff)
downloadtall.bot-7a564b835b6bc4ae7321a8ce74a7c891fd451701.tar.gz
Update style according to Flake8HEADmain
-rwxr-xr-xtallbot.py12
1 files changed, 11 insertions, 1 deletions
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> " + 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()