|
|
@ -74,15 +74,9 @@ MODES = { |
|
|
|
"light" : HIDE_CATEGORIES_LIGHT, |
|
|
|
"full" : HIDE_CATEGORIES_FULL |
|
|
|
} |
|
|
|
|
|
|
|
# Enable logging |
|
|
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
|
|
|
level=logging.INFO) |
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
with open("stoll.txt", "r") as tmp_file: |
|
|
|
STOLL = tmp_file.readlines() |
|
|
|
STOLL = open("stoll.txt", "r+") |
|
|
|
BRO = open("bro.txt", "r+") |
|
|
|
WAACK = open("waack.txt", "r+") |
|
|
|
|
|
|
|
with open("manta.txt", "r") as tmp_file: |
|
|
|
MANTA = tmp_file.readlines() |
|
|
@ -90,6 +84,25 @@ with open("manta.txt", "r") as tmp_file: |
|
|
|
with open("goodlife.txt", "r") as tmp_file: |
|
|
|
GOOD_LIFE = tmp_file.readlines() |
|
|
|
|
|
|
|
|
|
|
|
QUOTEPERSONS = { |
|
|
|
"stoll" : "Dr. Axel Stoll", |
|
|
|
"brosenne" : "Dr. Henrik Brosenne", |
|
|
|
"waack" : "Dr. Stephan Waack" |
|
|
|
} |
|
|
|
|
|
|
|
QUOTEFILES = { |
|
|
|
"stoll" : STOLL, |
|
|
|
"brosenne" : BRO, |
|
|
|
"waack" : WAACK |
|
|
|
} |
|
|
|
|
|
|
|
# Enable logging |
|
|
|
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
|
|
|
level=logging.INFO) |
|
|
|
|
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
|
|
|
|
# Define a few command handlers. These usually take the two arguments bot and |
|
|
|
# update. Error handlers also receive the raised TelegramError object in error. |
|
|
|
def start(bot, update): |
|
|
@ -182,6 +195,26 @@ def sudo(bot, update, args): |
|
|
|
else: |
|
|
|
update.message.reply_text("Unknown command") |
|
|
|
|
|
|
|
def addquote(bot, update, args): |
|
|
|
"""for real""" |
|
|
|
if not args : |
|
|
|
update.message.reply_text("missing params") |
|
|
|
return |
|
|
|
person = args[0] |
|
|
|
if person in QUOTEPERSONS: |
|
|
|
quote = "" |
|
|
|
quotefile = QUOTEFILES[person] |
|
|
|
argslenght = len(args) |
|
|
|
for argnum in range(1, argslenght): |
|
|
|
quote += args[argnum] |
|
|
|
if argnum != (argslenght - 1): |
|
|
|
quote += " " |
|
|
|
quotefile.write(quote + "\n") |
|
|
|
reopen(quotefile) |
|
|
|
update.message.reply_text("Added quote \"%s\" for %s" % (quote, QUOTEPERSONS[person])) |
|
|
|
else: |
|
|
|
update.message.reply_text("wrong params") |
|
|
|
|
|
|
|
def sendCatDog(bot, update): |
|
|
|
"""Best of both worlds!""" |
|
|
|
catdog = "https://upload.wikimedia.org/wikipedia/en/6/64/CatDog.jpeg" |
|
|
@ -249,8 +282,8 @@ def mensa(bot, update, args): |
|
|
|
meal_line = "*%s*\n" % meal["category"] |
|
|
|
meal_line += meal["title"].strip() + "\n" |
|
|
|
|
|
|
|
# Discord only allows up to 2000 chars per message |
|
|
|
if len(message) + len(meal_line) > 2000: |
|
|
|
# Telegram only allows up to 4096 chars per message |
|
|
|
if len(message) + len(meal_line) > 4096: |
|
|
|
update.message.reply_text(message, parse_mode=ParseMode.MARKDOWN) |
|
|
|
message = meal_line + "\n" |
|
|
|
else: |
|
|
@ -286,6 +319,8 @@ def main(): |
|
|
|
dp.add_handler(CommandHandler("manta", manta)) |
|
|
|
dp.add_handler(CommandHandler("goodlife", goodlife)) |
|
|
|
dp.add_handler(CommandHandler("mensa", mensa, pass_args=True)) |
|
|
|
dp.add_handler(CommandHandler("addquote", addquote, pass_args=True)) |
|
|
|
# dp.add_handler(CommandHandler("quote", quote, pass_args=True)) |
|
|
|
dp.add_handler(CommandHandler("sudo", sudo, pass_args=True)) |
|
|
|
dp.add_handler(CommandHandler("cat", sendCat)) |
|
|
|
dp.add_handler(CommandHandler("dog", sendDog)) |
|
|
|