# Armaan Bhojwani 2020
import sys
+import logging
import wikipedia
import discord
"What were", "who is", "Who is", "who was", "Who was",
"who were", "Who were", "who are", "Who are"]
-def wiki_sum(search, sen):
+def wiki_sum(search, sen, pid):
+ search = " ".join(search)
+
try:
- output = "From Wikipedia: " + wikipedia.summary(search, sentences=sen)
- except:
- output = "There was an error"
+ output = "<Wikipedia> " + wikipedia.summary(search, sentences=sen)
+ logging.info(str(pid) + " | " + search)
+ except Exception as e:
+ output = str(e)
+ logging.info(str(pid) + " | " + search + " | " + str(e))
return output
else:
return False
-class MyClient(discord.Client):
+class TallBot(discord.Client):
async def on_ready(self):
- print('Logged in as', self.user)
+ logging.debug('Logged in as ', self.user)
async def on_message(self, message):
if message.author == self.user:
return
if keyword_check(message.content):
- await message.channel.send(wiki_sum(message.content.split()[2:], 2))
+ await message.channel.send(wiki_sum(message.content.split()[2:],
+ 2,
+ message.author))
-client = MyClient()
+client = TallBot()
client.run(sys.argv[1])