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 approval(update, context): message = update.effective_message chat = update.effective_chat args = context.args user_id = extract_user(message, args) member = chat.get_member(int(user_id)) 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 "" if sql.is_approved(message.chat_id, user_id): message.reply_text( f"{member.user['first_name']} is an approved user. Locks, antiflood, and blocklists won't apply to them." ) else: message.reply_text( f"{member.user['first_name']} is not an approved user. They are affected by normal commands." )
def approve(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( "User is already admin - locks, blocklists, and antiflood already don't apply to them." ) return "" if sql.is_approved(message.chat_id, user_id): message.reply_text( f"[{member.user['first_name']}](tg://user?id={member.user['id']}) is already approved in {chat_title}", parse_mode=ParseMode.MARKDOWN, ) return "" sql.approve(message.chat_id, user_id) message.reply_text( f"[{member.user['first_name']}](tg://user?id={member.user['id']}) has been approved in {chat_title}! They will now be ignored by automated admin actions like locks, blocklists, and antiflood.", parse_mode=ParseMode.MARKDOWN, ) log_message = ( f"<b>{html.escape(chat.title)}:</b>\n" f"#APPROVED\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