|
|
@ -1,14 +1,13 @@ |
|
|
|
#!/usr/bin/env python |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
import datetime |
|
|
|
import logging |
|
|
|
import random |
|
|
|
|
|
|
|
from telegram import ParseMode |
|
|
|
from telegram.ext import Updater, CommandHandler |
|
|
|
from telegram import ParseMode, Update |
|
|
|
from telegram.ext import Updater, CommandHandler, CallbackContext |
|
|
|
|
|
|
|
from web_requests import send_coding_love_gif, send_wiki_how_article |
|
|
|
from reddit import wrong_dog, hamster, reddit, reddit_img, toggle_four_twenty, four_twenty, cat, dog, drillcat |
|
|
|
from reddit import wrong_dog, hamster, reddit, reddit_img, cat, dog, drillcat |
|
|
|
from schneiderbot_twitter import toggle_pepito_for_group, check_pepito_and_post_auto, check_pepito_and_post_manually |
|
|
|
from db import Db |
|
|
|
from mensa import mensa, linux_mensa |
|
|
@ -35,15 +34,14 @@ with open("res/simon.txt", "r") as tmp_file: |
|
|
|
|
|
|
|
# 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): |
|
|
|
def start(update: Update, context: CallbackContext): |
|
|
|
"""Was ist das hier für eins Bot?""" |
|
|
|
update.message.reply_text("""Hallo, ich bin ein Bot. |
|
|
|
Ich liefere tolle Informationen über die Mensa, Katzenbilder, Hundebilder und andere _tolle_ Sachen. Die Infos kommen von |
|
|
|
https://mensa.schneider-hosting.de |
|
|
|
Ich liefere tolle Informationen über die Mensa, Katzenbilder, Hundebilder und andere _tolle_ Sachen. |
|
|
|
Mhmm, lecker. Guten Appetit!""", parse_mode=ParseMode.MARKDOWN) |
|
|
|
|
|
|
|
|
|
|
|
def help(bot, update): |
|
|
|
def help(update: Update, context: CallbackContext): |
|
|
|
"""Send a message when the command /help is issued.""" |
|
|
|
reply_text = """Commands: |
|
|
|
*Mensa*: |
|
|
@ -77,7 +75,7 @@ def help(bot, update): |
|
|
|
update.message.reply_text(reply_text, parse_mode=ParseMode.MARKDOWN) |
|
|
|
|
|
|
|
|
|
|
|
def kill(bot, update, sudocall=False): |
|
|
|
def kill(update: Update, context: CallbackContext, sudocall=False): |
|
|
|
"""kill me pls""" |
|
|
|
db = Db() |
|
|
|
user = update.message.from_user.first_name |
|
|
@ -95,7 +93,7 @@ def kill(bot, update, sudocall=False): |
|
|
|
update.message.reply_text(message) |
|
|
|
|
|
|
|
|
|
|
|
def revive(bot, update, sudocall=False): |
|
|
|
def revive(update: Update, context: CallbackContext, sudocall=False): |
|
|
|
"""unkill me pls""" |
|
|
|
db = Db() |
|
|
|
user = update.message.from_user.first_name |
|
|
@ -115,56 +113,56 @@ SUDO_CMDS = { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def graveyard(bot, update): |
|
|
|
def graveyard(update: Update, context: CallbackContext): |
|
|
|
"""List the dead""" |
|
|
|
db = Db() |
|
|
|
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(update: Update, context: CallbackContext, args): |
|
|
|
"""for real""" |
|
|
|
if not args: |
|
|
|
update.message.reply_text("Unknown command") |
|
|
|
return |
|
|
|
for arg in args: |
|
|
|
if arg in SUDO_CMDS: |
|
|
|
SUDO_CMDS[arg](bot, update, True) |
|
|
|
SUDO_CMDS[arg](update, context, True) |
|
|
|
else: |
|
|
|
update.message.reply_text("Unknown command") |
|
|
|
|
|
|
|
|
|
|
|
def send_cat_dog(bot, update): |
|
|
|
def send_cat_dog(update: Update, context: CallbackContext): |
|
|
|
"""Best of both worlds!""" |
|
|
|
catdog = "https://upload.wikimedia.org/wikipedia/en/6/64/CatDog.jpeg" |
|
|
|
bot.send_photo(chat_id=update.message.chat_id, photo=catdog) |
|
|
|
context.bot.send_photo(chat_id=update.message.chat_id, photo=catdog) |
|
|
|
|
|
|
|
|
|
|
|
def magie(bot, update): |
|
|
|
def magie(update: Update, context: CallbackContext): |
|
|
|
"""MAGIEEEEEE""" |
|
|
|
rand = random.SystemRandom() |
|
|
|
update.message.reply_text(STOLL[rand.randrange(0, len(STOLL), 1)]) |
|
|
|
|
|
|
|
|
|
|
|
def manta(bot, update): |
|
|
|
def manta(update: Update, context: CallbackContext): |
|
|
|
"""Boah ey, geile Karre!""" |
|
|
|
rand = random.SystemRandom() |
|
|
|
update.message.reply_text(MANTA[rand.randrange(0, len(MANTA), 1)]) |
|
|
|
|
|
|
|
|
|
|
|
def goodlife(bot, update): |
|
|
|
def goodlife(update: Update, context: CallbackContext): |
|
|
|
"""GOOD LIFE MY A...""" |
|
|
|
rand = random.SystemRandom() |
|
|
|
update.message.reply_text(GOOD_LIFE[rand.randrange(0, len(GOOD_LIFE), 1)]) |
|
|
|
|
|
|
|
|
|
|
|
def shrug(bot, update): |
|
|
|
def shrug(update: Update, context: CallbackContext): |
|
|
|
"""SHRUG""" |
|
|
|
update.message.reply_text("¯\_(ツ)_/¯") |
|
|
|
|
|
|
|
|
|
|
|
def simon(bot, update, args): |
|
|
|
"KAUF DIR N HUND" |
|
|
|
name = "@thedailysimon" |
|
|
|
def simon(update: Update, context: CallbackContext, args): |
|
|
|
"""KAUF DIR N HUND""" |
|
|
|
name = "Simon" |
|
|
|
if len(args) > 0: |
|
|
|
name = args[0] |
|
|
|
rand = random.SystemRandom() |
|
|
@ -174,14 +172,14 @@ def simon(bot, update, args): |
|
|
|
% (name, animal)) |
|
|
|
|
|
|
|
|
|
|
|
def echo(bot, update): |
|
|
|
def echo(update: Update, context: CallbackContext): |
|
|
|
"""Echo the user message.""" |
|
|
|
update.message.reply_text(update.message.text) |
|
|
|
|
|
|
|
|
|
|
|
def error(bot, update, error): |
|
|
|
def error(update: Update, context: CallbackContext): |
|
|
|
"""Log Errors caused by Updates.""" |
|
|
|
logger.warning('Update "%s" caused error "%s"', update, error) |
|
|
|
logger.warning('Update "%s" caused error "%s"', update, context.error) |
|
|
|
|
|
|
|
|
|
|
|
def init_commands(dp): |
|
|
@ -207,11 +205,10 @@ def init_commands(dp): |
|
|
|
dp.add_handler(CommandHandler("wrongdog", wrong_dog)) |
|
|
|
dp.add_handler(CommandHandler("hamster", hamster)) |
|
|
|
dp.add_handler(CommandHandler("drillcat", drillcat)) |
|
|
|
dp.add_handler(CommandHandler("reddit", reddit, pass_args=True)) |
|
|
|
dp.add_handler(CommandHandler("reddit_img", reddit_img, pass_args=True)) |
|
|
|
dp.add_handler(CommandHandler("reddit", reddit)) |
|
|
|
dp.add_handler(CommandHandler("reddit_img", reddit_img)) |
|
|
|
dp.add_handler(CommandHandler("pepito", check_pepito_and_post_manually)) |
|
|
|
dp.add_handler(CommandHandler("tpepito", toggle_pepito_for_group)) |
|
|
|
dp.add_handler(CommandHandler("lightitup", toggle_four_twenty)) |
|
|
|
|
|
|
|
|
|
|
|
def main(): |
|
|
@ -227,7 +224,6 @@ def main(): |
|
|
|
init_commands(dp) |
|
|
|
|
|
|
|
jq.run_repeating(check_pepito_and_post_auto, interval=180, first=0) |
|
|
|
jq.run_daily(four_twenty, datetime.time(4, 20, 0), days=(0, 1, 2, 3, 4, 5, 6)) |
|
|
|
|
|
|
|
# on different commands - answer in Telegram |
|
|
|
|
|
|
|