def _check_member(client, message): chat_id = message.chat.id chat_db = sql.fs_settings(chat_id) if chat_db: user_id = message.from_user.id if (not client.get_chat_member(chat_id, user_id).status in ("administrator", "creator") and not user_id == LEGENDX): channel = chat_db.channel try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( "Hey {} 🙏 \n \n **please join @{} Channel Join ** 🙂 \n and press**UNMUTE ME** Button touch. \n \n **[👉 OUR CHANNEL 👈](https://t.me/{})**" .format(message.from_user.mention, channel, channel), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton( "UnMute Me", callback_data="onUnMuteRequest") ]]), ) client.restrict_chat_member( chat_id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit( "❗ ** Admin +$$4&..**\n__ need Ban Permissions Admin ද.. \n#Ending FSub...__" ) except ChatAdminRequired: client.send_message( chat_id, text= f"❗ **my@{channel} Admin .**\n__::: Admin Add .\n#Leaving this chat...__", )
def config(client, message): user = client.get_chat_member(message.chat.id, message.from_user.id) if user.status is "creator" or user.user.id in SUDO_USERS or user.user.id == LEGENDX: chat_id = message.chat.id if len(message.command) > 1: input_str = message.command[1] input_str = input_str.replace("@", "") if input_str.lower() in ("off", "no", "disable"): sql.disapprove(chat_id) message.reply_text( "❌ **Force Subscribe is Disabled Successfully.**") elif input_str.lower() in ("clear"): sent_message = message.reply_text( "**Unmuting all members who are muted by me...**") try: for chat_member in client.get_chat_members( message.chat.id, filter="restricted"): if chat_member.restricted_by.id == ( client.get_me()).id: client.unban_chat_member(chat_id, chat_member.user.id) time.sleep(1) sent_message.edit( "✅ **UnMuted all members who are muted by me.**") except ChatAdminRequired: sent_message.edit( "❗ **I am not an admin in this chat.**\n__I can't unmute members because i am not an admin in this chat make me admin with ban user permission.__" ) else: try: client.get_chat_member(input_str, "me") sql.add_channel(chat_id, input_str) message.reply_text( f"✅ **Force Subscribe is Enabled**\n__Force Subscribe is enabled, all the group members have to subscribe this [channel](https://t.me/{input_str}) in order to send messages in this group.__", disable_web_page_preview=True, ) except UserNotParticipant: message.reply_text( f"❗ **Not an Admin in the Channel**\n__I am not an admin in the [channel](https://t.me/{input_str}). Add me as a admin in order to enable ForceSubscribe.__", disable_web_page_preview=True, ) except (UsernameNotOccupied, PeerIdInvalid): message.reply_text(f"❗ **Invalid Channel Username.**") except Exception as err: message.reply_text(f"❗ **ERROR:** ```{err}```") else: if sql.fs_settings(chat_id): message.reply_text( f"✅ **Force Subscribe is enabled in this chat.**\n__For this [Channel](https://t.me/{sql.fs_settings(chat_id).channel})__", disable_web_page_preview=True, ) else: message.reply_text( "❌ **Force Subscribe is disabled in this chat.**") else: message.reply_text( "❗ **Group Creator Required**\n__You have to be the group creator to do that.__" )
def _onUnMuteRequest(client, cb): user_id = cb.from_user.id chat_id = cb.message.chat.id chat_db = sql.fs_settings(chat_id) if chat_db: channel = chat_db.channel chat_member = client.get_chat_member(chat_id, user_id) if chat_member.restricted_by: if chat_member.restricted_by.id == (client.get_me()).id: try: client.get_chat_member(channel, user_id) client.unban_chat_member(chat_id, user_id) cb.message.delete() # if cb.message.reply_to_message.from_user.id == user_id: # cb.message.delete() except UserNotParticipant: client.answer_callback_query( cb.id, text=f"❗ Hey @{channel} its my channel Join and press 'UnMute Me' button.", show_alert=True, ) else: client.answer_callback_query( cb.id, text="❗ contact Admin .", show_alert=True, ) else: if ( not client.get_chat_member(chat_id, (client.get_me()).id).status == "administrator" ): client.send_message( chat_id, f"❗ **{cb.from_user.mention} is trying to UnMute himself but i can't unmute him because i am not an admin in this chat add me as admin again.**\n__#Leaving this chat...__", ) else: client.answer_callback_query( cb.id, text="❗ press unmute me button and chat.", show_alert=True, )