|
@ -13,71 +13,71 @@ import cat |
|
|
import pydog |
|
|
import pydog |
|
|
|
|
|
|
|
|
DIETS = { |
|
|
DIETS = { |
|
|
"veggy" : "fleischlos", |
|
|
|
|
|
"fleisch" : "mit Fleisch", |
|
|
|
|
|
"fisch" : "mit Fisch/ Meeresfrüchten" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
"veggy": "fleischlos", |
|
|
|
|
|
"fleisch": "mit Fleisch", |
|
|
|
|
|
"fisch": "mit Fisch/ Meeresfrüchten" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
WEEKDAYS = { |
|
|
WEEKDAYS = { |
|
|
"montag" : 1, |
|
|
|
|
|
"dienstag" : 2, |
|
|
|
|
|
"mittwoch" : 3, |
|
|
|
|
|
"donnerstag" : 4, |
|
|
|
|
|
"freitag" : 5, |
|
|
|
|
|
"samstag" : 6 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
"montag": 1, |
|
|
|
|
|
"dienstag": 2, |
|
|
|
|
|
"mittwoch": 3, |
|
|
|
|
|
"donnerstag": 4, |
|
|
|
|
|
"freitag": 5, |
|
|
|
|
|
"samstag": 6 |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
MENSA_URL = { |
|
|
MENSA_URL = { |
|
|
"zentral": "zentralmensa", |
|
|
|
|
|
"nord": "nordmensa", |
|
|
|
|
|
"turm": "turmmensa", |
|
|
|
|
|
"italia": "mensaitalia", |
|
|
|
|
|
"fasthochschule": "bistrohawk" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
"zentral": "zentralmensa", |
|
|
|
|
|
"nord": "nordmensa", |
|
|
|
|
|
"turm": "turmmensa", |
|
|
|
|
|
"italia": "mensaitalia", |
|
|
|
|
|
"fasthochschule": "bistrohawk" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
MENSA_NAME = { |
|
|
MENSA_NAME = { |
|
|
"zentral": "Zentralmensa", |
|
|
|
|
|
"nord": "Nordmensa", |
|
|
|
|
|
"turm": "Turmmensa", |
|
|
|
|
|
"italia": "Mensa Italia", |
|
|
|
|
|
"fasthochschule": "Bistro Fasthochschule" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
"zentral": "Zentralmensa", |
|
|
|
|
|
"nord": "Nordmensa", |
|
|
|
|
|
"turm": "Turmmensa", |
|
|
|
|
|
"italia": "Mensa Italia", |
|
|
|
|
|
"fasthochschule": "Bistro Fasthochschule" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
HIDE_CATEGORIES_LIGHT = { |
|
|
HIDE_CATEGORIES_LIGHT = { |
|
|
"CampusCurry", |
|
|
|
|
|
"natürlich fit", |
|
|
|
|
|
"Fitnesscenter", |
|
|
|
|
|
"Salatbuffet", |
|
|
|
|
|
"Studentenfutter", |
|
|
|
|
|
"Süße Versuchung", |
|
|
|
|
|
"Süße Spezial Tagesangebot", |
|
|
|
|
|
"Vollwert & Co. Stärke", |
|
|
|
|
|
"Vollwert & Co. Gemüse", |
|
|
|
|
|
"Bio-Beilagen", |
|
|
|
|
|
"Dessertbuffet", |
|
|
|
|
|
"Last Minute ab 14:30 Uhr", |
|
|
|
|
|
## Nordmensa: |
|
|
|
|
|
"Salatbuffet/Pastapoint", |
|
|
|
|
|
"Last Minute ab 13:30 Uhr", |
|
|
|
|
|
## Turmmensa: |
|
|
|
|
|
"Beilagen", |
|
|
|
|
|
"Last Minute ab 14:00Uhr" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
"CampusCurry", |
|
|
|
|
|
"natürlich fit", |
|
|
|
|
|
"Fitnesscenter", |
|
|
|
|
|
"Salatbuffet", |
|
|
|
|
|
"Studentenfutter", |
|
|
|
|
|
"Süße Versuchung", |
|
|
|
|
|
"Süße Spezial Tagesangebot", |
|
|
|
|
|
"Vollwert & Co. Stärke", |
|
|
|
|
|
"Vollwert & Co. Gemüse", |
|
|
|
|
|
"Bio-Beilagen", |
|
|
|
|
|
"Dessertbuffet", |
|
|
|
|
|
"Last Minute ab 14:30 Uhr", |
|
|
|
|
|
## Nordmensa: |
|
|
|
|
|
"Salatbuffet/Pastapoint", |
|
|
|
|
|
"Last Minute ab 13:30 Uhr", |
|
|
|
|
|
## Turmmensa: |
|
|
|
|
|
"Beilagen", |
|
|
|
|
|
"Last Minute ab 14:00Uhr" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
HIDE_CATEGORIES_FULL = { |
|
|
HIDE_CATEGORIES_FULL = { |
|
|
"Last Minute ab 14:30 Uhr", |
|
|
|
|
|
"Last Minute ab 13:30 Uhr", |
|
|
|
|
|
"Last Minute ab 14:00Uhr" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
"Last Minute ab 14:30 Uhr", |
|
|
|
|
|
"Last Minute ab 13:30 Uhr", |
|
|
|
|
|
"Last Minute ab 14:00Uhr" |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
MODES = { |
|
|
MODES = { |
|
|
"light" : HIDE_CATEGORIES_LIGHT, |
|
|
|
|
|
"full" : HIDE_CATEGORIES_FULL |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
"light": HIDE_CATEGORIES_LIGHT, |
|
|
|
|
|
"full": HIDE_CATEGORIES_FULL |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
# Enable logging |
|
|
# Enable logging |
|
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
|
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
|
|
level=logging.INFO) |
|
|
|
|
|
|
|
|
level=logging.INFO) |
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
@ -90,6 +90,7 @@ with open("manta.txt", "r") as tmp_file: |
|
|
with open("goodlife.txt", "r") as tmp_file: |
|
|
with open("goodlife.txt", "r") as tmp_file: |
|
|
GOOD_LIFE = tmp_file.readlines() |
|
|
GOOD_LIFE = tmp_file.readlines() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Define a few command handlers. These usually take the two arguments bot and |
|
|
# Define a few command handlers. These usually take the two arguments bot and |
|
|
# update. Error handlers also receive the raised TelegramError object in error. |
|
|
# update. Error handlers also receive the raised TelegramError object in error. |
|
|
def start(bot, update): |
|
|
def start(bot, update): |
|
@ -99,6 +100,7 @@ def start(bot, update): |
|
|
https://mensa.schneider-hosting.de |
|
|
https://mensa.schneider-hosting.de |
|
|
Mhmm, lecker. Guten Appetit!""") |
|
|
Mhmm, lecker. Guten Appetit!""") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def help(bot, update): |
|
|
def help(bot, update): |
|
|
"""Send a message when the command /help is issued.""" |
|
|
"""Send a message when the command /help is issued.""" |
|
|
update.message.reply_text("""Commands: |
|
|
update.message.reply_text("""Commands: |
|
@ -119,6 +121,7 @@ def help(bot, update): |
|
|
/graveyard - shows the dead people |
|
|
/graveyard - shows the dead people |
|
|
/help - this help text""", parse_mode=ParseMode.MARKDOWN) |
|
|
/help - this help text""", parse_mode=ParseMode.MARKDOWN) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def sendCat(bot, update): |
|
|
def sendCat(bot, update): |
|
|
"""CUTE""" |
|
|
"""CUTE""" |
|
|
catfile = cat.getCat(); |
|
|
catfile = cat.getCat(); |
|
@ -131,14 +134,15 @@ def sendDog(bot, update): |
|
|
dog = pydog.PyDog() |
|
|
dog = pydog.PyDog() |
|
|
bot.send_photo(chat_id=update.message.chat_id, photo=dog.get_random_image()) |
|
|
bot.send_photo(chat_id=update.message.chat_id, photo=dog.get_random_image()) |
|
|
|
|
|
|
|
|
def kill(bot, update, sudocall = False): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def kill(bot, update, sudocall=False): |
|
|
"""kill me pls""" |
|
|
"""kill me pls""" |
|
|
db = Db() |
|
|
db = Db() |
|
|
user = update.message.from_user.first_name |
|
|
user = update.message.from_user.first_name |
|
|
if db.is_dead(user, update.message.chat_id): |
|
|
if db.is_dead(user, update.message.chat_id): |
|
|
if sudocall: |
|
|
if sudocall: |
|
|
update.message.reply_text("%s killed again" % user) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
update.message.reply_text("%s killed again" % user) |
|
|
|
|
|
return |
|
|
update.message.reply_text("%s is already dead" % user) |
|
|
update.message.reply_text("%s is already dead" % user) |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
@ -148,7 +152,8 @@ def kill(bot, update, sudocall = False): |
|
|
db.kill(user, update.message.chat_id) |
|
|
db.kill(user, update.message.chat_id) |
|
|
update.message.reply_text(message) |
|
|
update.message.reply_text(message) |
|
|
|
|
|
|
|
|
def revive(bot, update, sudocall = False): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def revive(bot, update, sudocall=False): |
|
|
"""unkill me pls""" |
|
|
"""unkill me pls""" |
|
|
db = Db() |
|
|
db = Db() |
|
|
user = update.message.from_user.first_name |
|
|
user = update.message.from_user.first_name |
|
@ -161,19 +166,22 @@ def revive(bot, update, sudocall = False): |
|
|
return |
|
|
return |
|
|
update.message.reply_text("You fool! You cannot revive a dead person!") |
|
|
update.message.reply_text("You fool! You cannot revive a dead person!") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SUDOCMDS = { |
|
|
SUDOCMDS = { |
|
|
"kill" : kill, |
|
|
|
|
|
"revive" : revive |
|
|
|
|
|
|
|
|
"kill": kill, |
|
|
|
|
|
"revive": revive |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def graveyard(bot, update): |
|
|
def graveyard(bot, update): |
|
|
"""List the dead""" |
|
|
"""List the dead""" |
|
|
db = Db() |
|
|
db = Db() |
|
|
update.message.reply_text("Here are the dead people:\n%s" % db.get_dead_bodies(update.message.chat_id)) |
|
|
update.message.reply_text("Here are the dead people:\n%s" % db.get_dead_bodies(update.message.chat_id)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def sudo(bot, update, args): |
|
|
def sudo(bot, update, args): |
|
|
"""for real""" |
|
|
"""for real""" |
|
|
if not args : |
|
|
|
|
|
|
|
|
if not args: |
|
|
update.message.reply_text("Unknown command") |
|
|
update.message.reply_text("Unknown command") |
|
|
return |
|
|
return |
|
|
for arg in args: |
|
|
for arg in args: |
|
@ -182,37 +190,44 @@ def sudo(bot, update, args): |
|
|
else: |
|
|
else: |
|
|
update.message.reply_text("Unknown command") |
|
|
update.message.reply_text("Unknown command") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def sendCatDog(bot, update): |
|
|
def sendCatDog(bot, update): |
|
|
"""Best of both worlds!""" |
|
|
"""Best of both worlds!""" |
|
|
catdog = "https://upload.wikimedia.org/wikipedia/en/6/64/CatDog.jpeg" |
|
|
catdog = "https://upload.wikimedia.org/wikipedia/en/6/64/CatDog.jpeg" |
|
|
bot.send_photo(chat_id=update.message.chat_id, photo=catdog) |
|
|
bot.send_photo(chat_id=update.message.chat_id, photo=catdog) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def magie(bot, update): |
|
|
def magie(bot, update): |
|
|
"""MAGIEEEEEE""" |
|
|
"""MAGIEEEEEE""" |
|
|
rand = random.SystemRandom() |
|
|
rand = random.SystemRandom() |
|
|
update.message.reply_text(STOLL[rand.randrange(0, len(STOLL), 1)]) |
|
|
update.message.reply_text(STOLL[rand.randrange(0, len(STOLL), 1)]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def manta(bot, update): |
|
|
def manta(bot, update): |
|
|
"""Boah ey, geile Karre!""" |
|
|
"""Boah ey, geile Karre!""" |
|
|
rand = random.SystemRandom() |
|
|
rand = random.SystemRandom() |
|
|
update.message.reply_text(MANTA[rand.randrange(0, len(MANTA), 1)]) |
|
|
update.message.reply_text(MANTA[rand.randrange(0, len(MANTA), 1)]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def goodlife(bot, update): |
|
|
def goodlife(bot, update): |
|
|
"""GOOD LIFE MY A...""" |
|
|
"""GOOD LIFE MY A...""" |
|
|
rand = random.SystemRandom() |
|
|
rand = random.SystemRandom() |
|
|
update.message.reply_text(GOOD_LIFE[rand.randrange(0, len(GOOD_LIFE), 1)]) |
|
|
update.message.reply_text(GOOD_LIFE[rand.randrange(0, len(GOOD_LIFE), 1)]) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def shrug(bot, update): |
|
|
def shrug(bot, update): |
|
|
"""SHRUG""" |
|
|
"""SHRUG""" |
|
|
update.message.reply_text("¯\_(ツ)_/¯") |
|
|
update.message.reply_text("¯\_(ツ)_/¯") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def simon(bot, update, args): |
|
|
def simon(bot, update, args): |
|
|
"KAUF DIR N HUND" |
|
|
"KAUF DIR N HUND" |
|
|
name = "[Simon](tg://user?id=47438109)" |
|
|
name = "[Simon](tg://user?id=47438109)" |
|
|
if len(args) > 0: |
|
|
|
|
|
name = " ".join(args[0:] |
|
|
|
|
|
|
|
|
if len(args) > 0: |
|
|
|
|
|
name = " ".join(args[0:]) |
|
|
update.message.reply_text("%s, bitte kauf dir einen Hund oder eine Katze, du hast zu viel Zeit" % name) |
|
|
update.message.reply_text("%s, bitte kauf dir einen Hund oder eine Katze, du hast zu viel Zeit" % name) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mensa(bot, update, args): |
|
|
def mensa(bot, update, args): |
|
|
which = "zentral" |
|
|
which = "zentral" |
|
|
filter_categories = MODES["light"] |
|
|
filter_categories = MODES["light"] |
|
@ -233,7 +248,7 @@ def mensa(bot, update, args): |
|
|
today = WEEKDAYS[arg] |
|
|
today = WEEKDAYS[arg] |
|
|
elif arg in DIETS: |
|
|
elif arg in DIETS: |
|
|
diet = DIETS[arg] |
|
|
diet = DIETS[arg] |
|
|
else: |
|
|
|
|
|
|
|
|
else: |
|
|
update.message.reply_text("Falscher Aufruf! RTFM und versuchs nochmal.") |
|
|
update.message.reply_text("Falscher Aufruf! RTFM und versuchs nochmal.") |
|
|
return |
|
|
return |
|
|
if today == 0: |
|
|
if today == 0: |
|
@ -252,7 +267,7 @@ def mensa(bot, update, args): |
|
|
meal_line = "*%s*\n" % meal["category"] |
|
|
meal_line = "*%s*\n" % meal["category"] |
|
|
meal_line += meal["title"].strip() + "\n" |
|
|
meal_line += meal["title"].strip() + "\n" |
|
|
|
|
|
|
|
|
# Discord only allows up to 2000 chars per message |
|
|
|
|
|
|
|
|
# Discord only allows up to 2000 chars per message |
|
|
if len(message) + len(meal_line) > 2000: |
|
|
if len(message) + len(meal_line) > 2000: |
|
|
update.message.reply_text(message, parse_mode=ParseMode.MARKDOWN) |
|
|
update.message.reply_text(message, parse_mode=ParseMode.MARKDOWN) |
|
|
message = meal_line + "\n" |
|
|
message = meal_line + "\n" |
|
@ -296,10 +311,9 @@ def main(): |
|
|
dp.add_handler(CommandHandler("shrug", shrug)) |
|
|
dp.add_handler(CommandHandler("shrug", shrug)) |
|
|
dp.add_handler(CommandHandler("kill", kill)) |
|
|
dp.add_handler(CommandHandler("kill", kill)) |
|
|
dp.add_handler(CommandHandler("revive", revive)) |
|
|
dp.add_handler(CommandHandler("revive", revive)) |
|
|
dp.add_handler(CommandHandler("simon", simon)) |
|
|
|
|
|
|
|
|
dp.add_handler(CommandHandler("simon", simon, pass_args=True)) |
|
|
dp.add_handler(CommandHandler("graveyard", graveyard)) |
|
|
dp.add_handler(CommandHandler("graveyard", graveyard)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# log all errors |
|
|
# log all errors |
|
|
dp.add_error_handler(error) |
|
|
dp.add_error_handler(error) |
|
|
|
|
|
|
|
|