async def disapprove_user(_, m: Message): chat_title = m.chat.title chat_id = m.chat.id user_id, user_first_name = await extract_user(m) if not user_id: await m.reply_text( "I don't know who you're talking about, you're going to need to specify a user!", ) return try: member = await m.get_member(user_id) except UserNotParticipant: if db.is_approved(chat_id, user_id): db.disapprove(chat_id, user_id) await m.reply_text("This user is not in this chat!") return except RPCError as ef: await m.reply_text( f"<b>Error</b>: <code>{ef}</code>\nReport it to @{SUPPORT_GROUP}", ) return if member.status in ["administrator", "creator"]: await m.reply_text("This user is an admin, they can't be unapproved.") return if not db.is_approved(chat_id, user_id): await m.reply_text( f"{(await mention_html(user_first_name, user_id))} isn't approved yet!", ) return db.disapprove(chat_id, user_id) await m.reply_text( f"{(await mention_html(user_first_name, user_id))} is no longer approved in {chat_title}.", ) return
async def disapprove_user(c: Alita, m: Message): res = await owner_check(c, m) if not res: return chat_title = m.chat.title chat_id = m.chat.id user_id, user_first_name = await extract_user(c, m) if not user_id: await m.reply_text( "I don't know who you're talking about, you're going to need to specify a user!" ) return member = await c.get_chat_member(chat_id=chat_id, user_id=user_id) if member.status in ["administrator", "creator"]: await m.reply_text("This user is an admin, they can't be unapproved.") return if not db.is_approved(chat_id, user_id): await m.reply_text( f"{mention_html(user_first_name, user_id)} isn't approved yet!" ) return db.disapprove(chat_id, user_id) await m.reply_text( f"{mention_html(user_first_name, user_id)} is no longer approved in {chat_title}." ) return
async def check_approved(_, m: Message): chat_title = m.chat.title chat = m.chat user_id = (await extract_user(m))[0] msg = "The following users are approved:\n" x = db.all_approved(m.chat.id) for i in x: try: member = await chat.get_member(int(i.user_id)) except UserNotParticipant: db.disapprove(chat.id, user_id) continue msg += f"- `{i.user_id}`: {(await mention_html(member.user['first_name'], int(i.user_id)))}\n" if msg.endswith("approved:\n"): await m.reply_text(f"No users are approved in {chat_title}.") return await m.reply_text(msg) return
async def check_approved(c: Alita, m: Message): res = await admin_check(c, m) if not res: return chat_title = m.chat.title chat = m.chat msg = "The following users are approved:\n" x = db.all_approved(m.chat.id) for i in x: try: member = await chat.get_member(int(i.user_id)) except errors.UserNotParticipant: db.disapprove(chat.id, user_id) continue msg += f"- `{i.user_id}`: {mention_html(member.user['first_name'], int(i.user_id))}\n" if msg.endswith("approved:\n"): await m.reply_text(f"No users are approved in {chat_title}.") return else: await m.reply_text(msg) return