print database
This commit is contained in:
parent
6917f489d3
commit
bc96b28091
1 changed files with 16 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import discord
|
import discord
|
||||||
|
import requests
|
||||||
|
|
||||||
# Read env variables
|
# Read env variables
|
||||||
bot_token = os.environ.get('DISCORDBOT_TOKEN', 'token')
|
bot_token = os.environ.get('DISCORDBOT_TOKEN', 'token')
|
||||||
|
@ -19,6 +20,18 @@ async def on_ready():
|
||||||
async def hello(message):
|
async def hello(message):
|
||||||
await message.channel.send('Hello!')
|
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
|
@client.event
|
||||||
async def on_message(message):
|
async def on_message(message):
|
||||||
if message.author == client.user:
|
if message.author == client.user:
|
||||||
|
@ -27,4 +40,7 @@ async def on_message(message):
|
||||||
if message.content.startswith('!hello'):
|
if message.content.startswith('!hello'):
|
||||||
await hello(message)
|
await hello(message)
|
||||||
|
|
||||||
|
if message.content.startswith('!epg'):
|
||||||
|
await epg(message)
|
||||||
|
|
||||||
client.run(bot_token)
|
client.run(bot_token)
|
Loading…
Reference in a new issue