def disapprove(update, context): message = update.effective_message chat_title = message.chat.title chat = update.effective_chat args = context.args user = update.effective_user user_id = extract_user(message, args) if not user_id: message.reply_text( "I don't know who you're talking about, you're going to need to specify a user!" ) return "" try: member = chat.get_member(user_id) except BadRequest: return "" if member.status == "administrator" or member.status == "creator": message.reply_text("This user is an admin, they can't be unapproved.") return "" if not sql.is_approved(message.chat_id, user_id): message.reply_text(f"{member.user['first_name']} isn't approved yet!") return "" sql.disapprove(message.chat_id, user_id) message.reply_text( f"{member.user['first_name']} is no longer approved in {chat_title}.") log_message = ( f"<b>{html.escape(chat.title)}:</b>\n" f"#UNAPPROVED\n" f"<b>Admin:</b> {mention_html(user.id, user.first_name)}\n" f"<b>User:</b> {mention_html(member.user.id, member.user.first_name)}") return log_message
def unapproveall_btn(update: Update, context: CallbackContext): query = update.callback_query chat = update.effective_chat message = update.effective_message member = chat.get_member(query.from_user.id) if query.data == "unapproveall_user": if member.status == "creator" or query.from_user.id in DRAGONS: approved_users = sql.list_approved(chat.id) users = [int(i.user_id) for i in approved_users] for user_id in users: sql.disapprove(chat.id, user_id) if member.status == "administrator": query.answer("Only owner of the chat can do this.") if member.status == "member": query.answer("You need to be admin to do this.") elif query.data == "unapproveall_cancel": if member.status == "creator" or query.from_user.id in DRAGONS: message.edit_text( "Removing of all approved users has been cancelled.") return "" if member.status == "administrator": query.answer("Only owner of the chat can do this.") if member.status == "member": query.answer("You need to be admin to do this.")