From bc96b28091b37b3d7990440855dfefa7e38490ec Mon Sep 17 00:00:00 2001 From: deflax Date: Tue, 16 Jan 2024 05:32:57 +0200 Subject: [PATCH] print database --- src/discordbot/app.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/discordbot/app.py b/src/discordbot/app.py index 0f542ee..1051053 100644 --- a/src/discordbot/app.py +++ b/src/discordbot/app.py @@ -1,5 +1,6 @@ import os import discord +import requests # Read env variables bot_token = os.environ.get('DISCORDBOT_TOKEN', 'token') @@ -19,6 +20,18 @@ async def on_ready(): async def hello(message): await message.channel.send('Hello!') +async def epg(message): + try: + db_url = f'https://{scheduler_hostname}/database' + if requests.get(db_url).status_code == 200: + response = requests.get(db_url) + response.raise_for_status() + + content = response.text + await message.channel.send(content) + except Exception as e: + print(e) + @client.event async def on_message(message): if message.author == client.user: @@ -26,5 +39,8 @@ async def on_message(message): if message.content.startswith('!hello'): await hello(message) + + if message.content.startswith('!epg'): + await epg(message) client.run(bot_token) \ No newline at end of file