You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

51 lines
1.3 KiB

#! /usr/bin/env python3
"""
Code for schneiderbot
"""
import os
import datetime
import discord
from discord.ext import commands
DESCRIPTION = '''Schneiderbot, bald mit tollen Funktionen'''
BOT = commands.Bot(command_prefix='!', description=DESCRIPTION)
MENSA_URL = {
"zentral": "zentralmensa",
"nord": "nordmensa"
}
@BOT.event
async def on_ready():
""" On ready """
print('Logged in as')
print(BOT.user.name)
print(BOT.user.id)
print('------')
@BOT.command()
async def hello():
"""Says world"""
await BOT.say("world")
@BOT.command()
async def mensa(which="zentral"):
"""Gibt leckere, äh, nützliche Infos über die Mensa aus.
Standardmäßig für die Zentralmensa, aber probier auch mal nord aus."""
today = datetime.datetime.now().date().weekday() + 1
if datetime.datetime.now().time() > datetime.time(hour=16):
# Es ist zu spät am Tag, zeig das essen für morgen an
today += 1
await BOT.say("""Hallo, ich bin ein Bot.
Hier gibt es tolle Infos über das Essen in der Mensa:
https://mensa.schneider-hosting.de/%s/%d
Mhmm, lecker. Guten Appetit!""" % (MENSA_URL[which], today))
def main():
""" entry point """
BOT.run(os.environ['SCHNEIDERBOT_TOKEN'])
if __name__ == '__main__':
main()