def insults(bot: Bot, update: Update): message = update.effective_message chat = update.effective_chat text = random.choice(tld_list(chat.id, "memes_insults_list")) if message.reply_to_message: message.reply_to_message.reply_text(text) else: message.reply_text(text)
def do_translate(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat # type: Optional[Chat] msg = update.effective_message # type: Optional[Message] lan = " ".join(args) if msg.reply_to_message and (msg.reply_to_message.audio or msg.reply_to_message.voice) or ( args and args[0] == 'animal'): reply = random.choice(tld_list(chat.id, 'translator_animal_lang')) if args: translation_type = "text" else: translation_type = "audio" msg.reply_text(tld(chat.id, 'translator_animal_translated').format( translation_type, reply), parse_mode=ParseMode.MARKDOWN) return if msg.reply_to_message: to_translate_text = remove_emoji(msg.reply_to_message.text) else: msg.reply_text(tld(chat.id, "translator_no_str")) return if not args: msg.reply_text(tld(chat.id, 'translator_no_args')) return translator = Translator() try: translated = translator.translate(to_translate_text, dest=lan) except ValueError as e: msg.reply_text(tld(chat.id, 'translator_err').format(e)) src_lang = LANGUAGES[f'{translated.src.lower()}'].title() dest_lang = LANGUAGES[f'{translated.dest.lower()}'].title() translated_text = translated.text msg.reply_text(tld(chat.id, 'translator_translated').format(src_lang, to_translate_text, dest_lang, translated_text), parse_mode=ParseMode.MARKDOWN)
def slap(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat msg = update.effective_message # reply to correct message reply_text = msg.reply_to_message.reply_text if msg.reply_to_message else msg.reply_text # get user who sent message if msg.from_user.username: curr_user = "******" + escape_markdown(msg.from_user.username) else: curr_user = "******".format(msg.from_user.first_name, msg.from_user.id) user_id = extract_user(update.effective_message, args) if user_id: slapped_user = bot.get_chat(user_id) user1 = curr_user if slapped_user.username == "RealAkito": reply_text(tld(chat.id, "jokes_not_doing_that")) return if slapped_user.username: user2 = "@" + escape_markdown(slapped_user.username) else: user2 = "[{}](tg://user?id={})".format(slapped_user.first_name, slapped_user.id) # if no target found, bot targets the sender else: user1 = "[{}](tg://user?id={})".format(bot.first_name, bot.id) user2 = curr_user temp = random.choice(tld_list(chat.id, "jokes_slaps_templates_list")) item = random.choice(tld_list(chat.id, "jokes_items_list")) hit = random.choice(tld_list(chat.id, "jokes_hit_list")) throw = random.choice(tld_list(chat.id, "jokes_throw_list")) itemp = random.choice(tld_list(chat.id, "jokes_items_list")) itemr = random.choice(tld_list(chat.id, "jokes_items_list")) repl = temp.format(user1=user1, user2=user2, item=item, hits=hit, throws=throw, itemp=itemp, itemr=itemr) reply_text(repl, parse_mode=ParseMode.MARKDOWN)
def runs(bot: Bot, update: Update): chat = update.effective_chat update.effective_message.reply_text( random.choice(tld_list(chat.id, "jokes_runs_list")))