def set_about_bio(bot: Bot, update: Update): chat = update.effective_chat message = update.effective_message sender = update.effective_user if message.reply_to_message: repl_message = message.reply_to_message user_id = repl_message.from_user.id if user_id == message.from_user.id: message.reply_text(tld(chat.id, 'userinfo_bio_you_cant_set')) return elif user_id == bot.id and sender.id not in SUDO_USERS: message.reply_text(tld(chat.id, 'userinfo_bio_bot_sudo_only')) return elif user_id in SUDO_USERS and sender.id not in SUDO_USERS: message.reply_text(tld(chat.id, 'userinfo_bio_sudo_sudo_only')) return elif user_id == OWNER_ID: message.reply_text(tld(chat.id, 'userinfo_bio_owner_nobio')) return text = message.text bio = text.split( None, 1 ) # use python's maxsplit to only remove the cmd, hence keeping newlines. if len(bio) == 2: if len(bio[1]) < MAX_MESSAGE_LENGTH // 4: sql.set_user_bio(user_id, bio[1]) message.reply_text("Updated {}'s bio!".format( repl_message.from_user.first_name)) else: message.reply_text( tld(chat.id, 'userinfo_bio_too_long').format( MAX_MESSAGE_LENGTH // 4, len(bio[1]))) else: message.reply_text(tld(chat.id, 'userinfo_bio_set_no_reply'))
def set_about_bio(bot: Bot, update: Update): message = update.effective_message # type: Optional[Message] sender = update.effective_user # type: Optional[User] if message.reply_to_message: repl_message = message.reply_to_message user_id = repl_message.from_user.id if user_id == message.from_user.id: message.reply_text("Ha, you can't set your own bio! You're at the mercy of others here...") return elif user_id == bot.id and sender.id not in SUDO_USERS: message.reply_text("Erm... yeah, I only trust sudo users to set my bio LMAO.") return elif user_id in SUDO_USERS and sender.id not in SUDO_USERS: message.reply_text("Erm... yeah, I only trust sudo users to set sudo users bio LMAO.") return elif user_id == OWNER_ID: message.reply_text("You ain't setting my master bio LMAO.") return text = message.text bio = text.split(None, 1) # use python's maxsplit to only remove the cmd, hence keeping newlines. if len(bio) == 2: if len(bio[1]) < MAX_MESSAGE_LENGTH // 4: sql.set_user_bio(user_id, bio[1]) message.reply_text("Updated {}'s bio!".format(repl_message.from_user.first_name)) else: message.reply_text( "A bio needs to be under {} characters! You tried to set {}.".format( MAX_MESSAGE_LENGTH // 4, len(bio[1]))) else: message.reply_text("Reply to someone's message to set their bio!")