Browse Source

fixed day 0 bug; reformatted

quotes
angerstoner 6 years ago
parent
commit
21988f52ad
  1. 45
      schneiderbot.py

45
schneiderbot.py

@ -15,7 +15,7 @@ DIETS = {
"veggy" : "fleischlos",
"fleisch" : "mit Fleisch",
"fisch" : "mit Fisch/ Meeresfrüchten"
}
}
WEEKDAYS = {
"montag" : 1,
@ -24,19 +24,19 @@ WEEKDAYS = {
"donnerstag" : 4,
"freitag" : 5,
"samstag" : 6
}
}
MENSA_URL = {
"zentral": "zentralmensa",
"nord": "nordmensa",
"turm": "turmmensa"
}
}
MENSA_NAME = {
"zentral": "Zentralmensa",
"nord": "Nordmensa",
"turm": "Turmmensa"
}
}
HIDE_CATEGORIES_LIGHT = {
"CampusCurry",
@ -57,18 +57,18 @@ HIDE_CATEGORIES_LIGHT = {
## Turmmensa:
"Beilagen",
"Last Minute ab 14:00Uhr"
}
}
HIDE_CATEGORIES_FULL = {
"Last Minute ab 14:30 Uhr",
"Last Minute ab 13:30 Uhr",
"Last Minute ab 14:00Uhr"
}
}
MODES = {
"light" : HIDE_CATEGORIES_LIGHT,
"full" : HIDE_CATEGORIES_FULL
}
}
# Enable logging
@ -88,24 +88,24 @@ with open("manta.txt", "r") as tmp_file:
def start(bot, update):
"""Was ist das hier für eins Bot?"""
update.message.reply_text("""Hallo, ich bin ein Bot.
Ich liefere tolle Informationen über die Mensa. Die Infos kommen von
https://mensa.schneider-hosting.de
Mhmm, lecker. Guten Appetit!""")
Ich liefere tolle Informationen über die Mensa. Die Infos kommen von
https://mensa.schneider-hosting.de
Mhmm, lecker. Guten Appetit!""")
def help(bot, update):
"""Send a message when the command /help is issued."""
update.message.reply_text("""Commands:
*Mensa*:
/mensa _mensa_ - prints filtered list of meals for _mensa_ (if no _mensa_ given, zentralmensa is used)
/mensa _mensa_ full - prints full list of meals for _mensa_ (if no _mensa_ given, zentralmensa is used)
*Mensa*:
/mensa _mensa_ - prints filtered list of meals for _mensa_ (if no _mensa_ given, zentralmensa is used)
/mensa _mensa_ full - prints full list of meals for _mensa_ (if no _mensa_ given, zentralmensa is used)
*Fun*:
/cat - random cat (using thecatapi.com)
/dog - random dog (https://dog.ceo/dog-api)
/magie - random Axel Stoll qoute
/manta - random Opel Manta joke
*Fun*:
/cat - random cat (using thecatapi.com)
/dog - random dog (https://dog.ceo/dog-api)
/magie - random Axel Stoll qoute
/manta - random Opel Manta joke
/help - this help text""", parse_mode=ParseMode.MARKDOWN)
/help - this help text""", parse_mode=ParseMode.MARKDOWN)
def sendCat(bot, update):
"""CUTE"""
@ -152,10 +152,9 @@ def mensa(bot, update, args):
today += 1
today = today % 7
for arg in args:
if arg in MENSA_NAME:
which = args[0]
which = arg
elif arg in MODES:
filter_categories = MODES[arg]
elif arg in WEEKDAYS:
@ -165,7 +164,9 @@ def mensa(bot, update, args):
else:
update.message.reply_text("Falscher Aufruf! RTFM und versuchs nochmal.")
return
if today == 0:
update.message.reply_text("Sonntags hat die Mensa zu")
return
url = "https://mensa.schneider-hosting.de/static/%s.%d.json" % (MENSA_URL[which], today)
request = requests.get(url)
request.encoding = 'utf-8'

Loading…
Cancel
Save