From 3a18c03ddcc8a95dcc07d5e9f3be379839c18a50 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 26 Oct 2023 11:45:15 -0700 Subject: [PATCH] allow you to mention dale-bot and he'll query wolfram --- app/bot.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/bot.py b/app/bot.py index 8ef5507d..77788ca8 100755 --- a/app/bot.py +++ b/app/bot.py @@ -133,4 +133,19 @@ async def fix_tiktok_links(ctx): return +@bot.event +async def on_message(ctx): + if str(bot.user.id) in ctx.content: + import wolframalpha + + client = wolframalpha.Client(os.getenv("wolfram_token")) + query = " ".join(ctx.content.split()[1:]) + try: + res = client.query(query) + return await ctx.reply(next(res.results).text) + except Exception as e: + print(e) + return await ctx.reply("Sorry, I'm unable to answer that") + + bot.run(os.getenv("discord_token"))