def SendMsg(client, message): cws = sql.fs_settings(message.chat.id) if not cws: return user_id = message.from_user.id first_name = message.from_user.first_name CHANNEL_USERNAME = cws.channel try: client.get_chat_member(CHANNEL_USERNAME, user_id) return except pyrogram.errors.exceptions.bad_request_400.UserNotParticipant: if client.get_chat_member(message.chat.id, user_id).status in ("administrator", "creator"): return message.reply_text( "[{}](tg://user?id={}), you are **not subscribed** to my [channel](https://t.me/{}) yet. Please [join](https://t.me/{}) and **press the button below** to unmute yourself." .format(first_name, user_id, CHANNEL_USERNAME, CHANNEL_USERNAME), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("UnMute Me", callback_data="onButtonPress") ]])) client.restrict_chat_member(message.chat.id, user_id, ChatPermissions(can_send_messages=False)) except pyrogram.errors.exceptions.bad_request_400.ChatAdminRequired: client.send_message(message.chat.id, text=f"I am not an admin in @{CHANNEL_USERNAME}") except ValueError: client.send_message(message.chat.id, text=f"I am not an admin in @{CHANNEL_USERNAME}")
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 in Config.SUDO_USERS: channel = chat_db.channel try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( "{}, kamu **belom subs** [channel](https://t.me/{}) klik dulu [join](https://t.me/{}) trus **klik tombol unmute** biar bisa ngetik.".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("❗ **I am not an admin here.**\n__Make me admin with ban user permission and add me again.\n#Leaving this chat...__") client.leave_chat(chat_id) except ChatAdminRequired: client.send_message(chat_id, text=f"❗ **I am not an admin in @{channel}**\n__Make me admin in the channel and add me again.\n#Leaving this chat...__") client.leave_chat(chat_id)
def SendMsg(client, message): cws = sql.fs_settings(message.chat.id) if cws: user_id = message.from_user.id if not client.get_chat_member(message.chat.id, user_id).status in ( "administrator", "creator") and not user_id in Config.SUDO_USERS: first_name = message.from_user.first_name channel = cws.channel try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( "ℹ [{}](tg://user?id={}), You Are **Not Subscribed** To My [Channel](https://t.me/{}) Yet. Please 👉 [Join](https://t.me/{}) And **Press The Button Below** [👇](https://telegra.ph/file/e058c8f4a2a8355ccf4fa.jpg) To Unmute Yourself." .format(first_name, user_id, channel, channel), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("🔔 UnMute Me 🔕", callback_data="onButtonPress") ]])) client.restrict_chat_member( message.chat.id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit( "❗ **I'm Not An Admin In Here.**\nMake Me Admin With Ban User Permission Or Turn Off ForceSubscribe." ) except ChatAdminRequired: client.send_message( message.chat.id, text= f"❗ **I'm Not An Admin In @{channel}**\nMake Me Admin In The Channel Or Turn Of ForceSubscribe." )
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 in Config.SUDO_USERS: channel = chat_db.channel try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( "{}, you are **Not Subscribed** to my [CHANNEL](https://t.me/{}) yet. Please Join @{} and Press the **Unmute Me** button below to unmute yourself.".format(message.from_user.mention, channel, channel), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup( [ [ InlineKeyboardButton('📢 Join Channel 📢', url=f"https://t.me/{channel}") ], [ InlineKeyboardButton("🔊 Unmute Me 🔊", callback_data="onUnMuteRequest") ] ] ) ) client.restrict_chat_member(chat_id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit("❗ **I am not an admin here.**\n__Make me admin with ban user permission and add me again.\n#Leaving this chat...__") client.leave_chat(chat_id) except ChatAdminRequired: client.send_message(chat_id, text=f"❗ **I am not an admin in @{channel}**\n__Make me admin in the channel and add me again.\n#Leaving this chat...__") client.leave_chat(chat_id)
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 Config.SUDO_USERS: 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 Berhasil Dinonaktifkan.**") elif input_str.lower() in ('clear'): sent_message = message.reply_text( '**Membatalkan aksi pembisuan semua anggota yang dibisukan oleh saya...**' ) 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( '✅ **Mensuarakan semua anggota yang dibisukan oleh saya.**' ) except ChatAdminRequired: sent_message.edit( '❗ **Saya bukan admin dalam obrolan ini.**\n__Saya tidak dapat membisukan anggota karena saya bukan admin dalam obrolan ini, jadikan saya admin dengan izin blokir pengguna.__' ) else: try: client.get_chat_member(input_str, "me") sql.add_channel(chat_id, input_str) message.reply_text( f"✅ **Force Subscribe berhasil diaktifkan, semua anggota grup harus bergabung di [channel](https://t.me/{input_str}) ini untuk dapat mengirim pesan dengan bebas.__", disable_web_page_preview=True) except UserNotParticipant: message.reply_text( f"❗ **Bukan Admin di Channel**\n__Saya bukan admin di [channel](https://t.me/{input_str}). Tambahkan saya sebagai admin untuk mengaktifkan Fitur ini.__", disable_web_page_preview=True) except (UsernameNotOccupied, PeerIdInvalid): message.reply_text(f"❗ **Username Channel tidak benar.**") except Exception as err: message.reply_text(f"❗ **ERROR:** ```{err}```") else: if sql.fs_settings(chat_id): message.reply_text( f"✅ **Force Subscribe diaktifkan dalam obrolan ini.**\n__Untuk [Channel](https://t.me/{sql.fs_settings(chat_id).channel})__", disable_web_page_preview=True) else: message.reply_text( "❌ **Force Subscribe dinonaktifkan dalam obrolan ini.**") else: message.reply_text( "❗ **Pemilik Grup Diperlukan**\n__Anda harus menjadi pemilik grup untuk mengaktifkannya.__" )
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 Config.SUDO_USERS: 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( "❌ **Perintah Subscribe Dinonaktifkan 'Berhasil'.**") elif input_str.lower() in ('clear'): sent_message = message.reply_text( '**Menormalkan kembali semua member yang dibisukan...**') 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( '✅ **Menormalkan kembali semua member yang dibisukan.**' ) except ChatAdminRequired: sent_message.edit( '❗ **Saya bukan admin di chat ini.**\n__saya dak pacak unmute members krna bukan admin di grup ini, jadikan aku admin dan izinkan perintah banned user ya.__' ) else: try: client.get_chat_member(input_str, "me") sql.add_channel(chat_id, input_str) message.reply_text( f"✅ **Force Subscribe Di Aktifkan**\n__Force Subscribe lah diaktifkan ya, semua member grup harus subscribe/join ke channel >> [channel](https://t.me/{input_str}) supaya bisa chat di grup kembali.__", disable_web_page_preview=True) except UserNotParticipant: message.reply_text( f"❗ **aku bukan admin dichannel**\n__Aku bukan admin di channel >> [channel](https://t.me/{input_str}). tambahkan aku sebagai admin untuk Mengaktifkan ForceSubscribe.__", disable_web_page_preview=True) except (UsernameNotOccupied, PeerIdInvalid): message.reply_text( f"❗ **Nama 'Username Channelnya' salah ouy.**") except Exception as err: message.reply_text(f"❗ **neh salah :** ```{err}```") else: if sql.fs_settings(chat_id): message.reply_text( f"✅ **Alhamdulillah Force Subscribe telah diaktifkan di sini.**\n__Silahkan Follow yaa >>> [Channel](https://t.me/{sql.fs_settings(chat_id).channel})__", disable_web_page_preview=True) else: message.reply_text( "❌ **Hmm... Force Subscribe tidak diaktifkan di sini.**") else: message.reply_text( "❗ **Kita kenal ?**\n__Maaf mengatakan ini :p Sepertinya kita belum saling mengenal wkwk.__" )
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 Config.SUDO_USERS: 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( '✅ **Finally 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"✅ **Great 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( "❌ **Oops, 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 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 Config.SUDO_USERS: 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 fsub(client, message): user = client.get_chat_member(message.chat.id, message.from_user.id) if user.status is "creator" or user.user.id in Config.SUDO_USERS: 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("❌ **Desactivado correctamente.**") elif input_str.lower() in ('clear'): sent_message = message.reply_text('**Actualizando...**') 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( '✅ **Ya pueden escribir todos los miembros que he silenciado.**' ) except ChatAdminRequired: sent_message.edit( '❗ **No soy administrador en este grupo.**\n__No puedo silenciar a los miembros si no me otorgas todos los permisos.__' ) else: try: client.get_chat_member(input_str, "me") sql.add_channel(chat_id, input_str) message.reply_text( f"✅ **El bot está habilitado**\n__Todos los mimbros del grupo tendrán que estar suscrito a [Anuncios_cu](https://t.me/{input_str}) para poder enviar mensajes al grupo.__", disable_web_page_preview=True) except UserNotParticipant: message.reply_text( f"❗ **No soy administrador en el canal.**\n__Añádeme a [channel](https://t.me/{input_str}). Y otórgame todos los permisos.__", disable_web_page_preview=True) except (UsernameNotOccupied, PeerIdInvalid): message.reply_text(f"❗ **Username del canal inválido.**") except Exception as err: message.reply_text(f"❗ **ERROR:** ```{err}```") else: if sql.fs_settings(chat_id): message.reply_text( f"✅ **Está activo en este grupo.**\n__Para el Canal [Channel](https://t.me/{sql.fs_settings(chat_id).channel})__", disable_web_page_preview=True) else: message.reply_text("❌ **No está activado en este grupo.**") else: message.reply_text( "❗ **Creador del grupo requerido.**\n__Tienes que ser el creador del grupo para usar el bot acá.__" )
def onButtonPress(client, cb): user_id = cb.from_user.id chat_id = cb.message.chat.id cws = sql.fs_settings(chat_id) if cws: CHANNEL_USERNAME = cws.channel try: client.get_chat_member(CHANNEL_USERNAME, user_id) client.unban_chat_member(chat_id, user_id) except pyrogram.errors.exceptions.bad_request_400.UserNotParticipant: client.answer_callback_query( cb.id, text="Join the channel and press the button again.")
def config(client, message): user = client.get_chat_member(message.chat.id, message.from_user.id) if user.status == "creator" or user.user.id in Config.SUDO_USERS: 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: swo, wso = get_valid_channels(message) if not swo: message.reply_text(wso, disable_web_page_preview=True) return input_str = ".".join(wso) mmo = "@" + " @".join(wso) 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 these {mmo} channels in order to send messages in this group.__", disable_web_page_preview=True) 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 onButtonPress(client, cb): user_id = cb.from_user.id chat_id = cb.message.chat.id cws = sql.fs_settings(chat_id) if cws: channel = cws.channel if client.get_chat_member(chat_id, user_id).restricted_by.id == (client.get_me()).id: try: client.get_chat_member(channel, user_id) client.unban_chat_member(chat_id, user_id) except UserNotParticipant: client.answer_callback_query(cb.id, text="Join the channel and press the button again.") else: client.answer_callback_query(cb.id, text="You are muted by admins for other reasons.", show_alert=True)
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 in Config.SUDO_USERS: channel = chat_db.channel if channel.startswith("-"): channel_url = client.export_chat_invite_link(int(channel)) else: channel_url = f"https://t.me/{channel}" try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( " **{} Muted 🔕** \n\n** 📍Mandatory [Channel](https://t.me/{}) Subscription Required** .\n\n__For **Unmuting** yourself, DO ⬇️.__\n\n**➠Step 1 Join Our [Channel](https://t.me/{}) ** \n**➠Step 2 After Joining . Click Below button 👇 ( **Unmute me** ) 👇.**" .format(message.from_user.mention, channel, channel), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup( [[ InlineKeyboardButton("Subscribe My Channel", url=channel_url) ], [ InlineKeyboardButton( "UnMute Me", callback_data="onUnMuteRequest") ]])) client.restrict_chat_member( chat_id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit( "❗ **I am not an admin here.**\n__Make me admin with ban user permission and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id) except ChatAdminRequired: client.send_message( chat_id, text= f"❗ **I am not an admin in [channel]({channel_url})**\n__Make me admin in the channel and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id)
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 in Config.SUDO_USERS: channel = chat_db.channel try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( "{}, anda belum **Bergabung** di [CHANNEL](https://t.me/{}) kami. Silahkan bergabung di @{} dan tekan tombol **Suarakan Saya** lagi untuk dapat berbicara dengan bebas." .format(message.from_user.mention, channel, channel), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([ [ #InlineKeyboardButton("Suarakan Saya", callback_data="onUnMuteRequest") InlineKeyboardButton( '📡 Gabung Channel 📡', url=f"https://t.me/{channel}") ], [ #InlineKeyboardButton('Gabung Channel', url=f"https://t.me/{channel}") InlineKeyboardButton( "🔇 Suarakan Saya 🔇", callback_data="onUnMuteRequest") ] ])) client.restrict_chat_member( chat_id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit( "❗ **Saya bukan admin di sini.**\n__Jadikan saya admin dengan izin pengguna blokir dan tambahkan saya lagi.\n#Leaving this chat...__" ) client.leave_chat(chat_id) except ChatAdminRequired: client.send_message( chat_id, text= f"❗ **Saya bukan admin di saluran @{channel}**\n__Jadikan saya admin di saluran dan tambahkan saya lagi.\n#Leaving this chat...__" ) client.leave_chat(chat_id)
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 in Config.SUDO_USERS: channel = chat_db.channel if channel.startswith("-"): channel_url = client.export_chat_invite_link(int(channel)) else: channel_url = f"https://t.me/{channel}" try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( " {} , you are not subscribed to my channel yet. Please join using below button and press the UnMute Me button to unmute yourself." .format(message.from_user.mention, channel, channel), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup( [[ InlineKeyboardButton("🎉Subscribe My Channel🎉", url=channel_url) ], [ InlineKeyboardButton( "❌UnMute Me❌", callback_data="onUnMuteRequest") ]])) client.restrict_chat_member( chat_id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit( "❗ **I am not an admin here.**\n__Make me admin with ban user permission and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id) except ChatAdminRequired: client.send_message( chat_id, text= f"❗ **I am not an admin in [channel]({channel_url})**\n__Make me admin in the channel and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id)
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_s = chat_db.channel.split(".") 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: n_subscription_s = [] for channel in channel_s: try: client.get_chat_member(channel, user_id) except UserNotParticipant: n_subscription_s.append(channel) if len(n_subscription_s) > 0: client.answer_callback_query( cb.id, text= "❗ Join the mentioned 'channel(s)' and press the 'UnMute Me' button again.", show_alert=True) else: client.unban_chat_member(chat_id, user_id) if cb.message.reply_to_message.from_user.id == user_id: cb.message.delete() else: client.answer_callback_query( cb.id, text="❗ You are muted by admins for other reasons.", 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...__" ) client.leave_chat(chat_id) else: client.answer_callback_query( cb.id, text= "❗ Warning: Don't click the button if you can speak freely.", show_alert=True)
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 in Config.SUDO_USERS: channel = chat_db.channel try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( "Hi {}, You Are **Not Subscribed** To My [Channel](https://t.me/{}) Yet. Please 👉 [Join](https://t.me/{}) And **Press The Button Below** 👇 To Unmute Yourself." .format(message.from_user.mention, channel, channel), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup( [[ InlineKeyboardButton( "🔔 UNMUTE ME 🔕", callback_data="onUnMuteRequest") ]], [[ InlineKeyboardButton( "🔔 SUBSCRIBE 🔕", url="http://t.me/mpazaanbots") ]], )) client.restrict_chat_member( chat_id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit( "❗ **I am not an admin here.**\n__Make me admin with ban user permission and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id) except ChatAdminRequired: client.send_message( chat_id, text= f"❗ **I am not an admin in @{channel}**\n__Make me admin in the channel and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id)
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 in Config.SUDO_USERS: channels = chat_db.channel.split(".") n_subscription_s = [] for channel in channels: try: client.get_chat_member(channel, user_id) except UserNotParticipant: n_subscription_s.append(channel) except ChatAdminRequired: client.send_message( chat_id, text= f"❗ **I am not an admin in @{channel}**\n__Make me admin in the channel and add me again.\n#Leaving this chat...__" ) sql.disapprove(chat_id) client.leave_chat(chat_id) return if len(n_subscription_s) > 0: mmo = "@" + " @".join(n_subscription_s) try: sent_message = message.reply_text( "{}, you are **not subscribed** to my channels: {mmo} yet. Please [join](https://t.me/{}) and **press the button below** to unmute yourself." .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( "❗ **I am not an admin here.**\n__Make me admin with ban user permission and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id)
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 in Config.SUDO_USERS: channel = chat_db.channel try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( "**ආයුබෝවන් {} 🙏\n\nඔයා අපේ @{} Channel එකට තාම Join වෙලා නෑ 🥺\nකරුණාකරල ඒකට Join වෙලා පහල තියන 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( "Join Channel", url="https://t.me/{}".format(channel)) ], [ 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 නෙමෙයි..**\n__මට Ban Permissions එක්ක Admin දීල ආපහු උත්සාහ කරන්න.. \n#Leaving this chat...__" ) client.leave_chat(chat_id) except ChatAdminRequired: client.send_message( chat_id, text= f"❗ **මම @{channel} එකේ Admin නෙමෙයි.**\n__මට ඒකෙ Admin දීල ආපහු Add කරන්න.\n#Leaving this chat...__" ) client.leave_chat(chat_id)
def config(client, message): user = client.get_chat_member(message.chat.id, message.from_user.id) if user.status is "creator": chat_id = message.chat.id try: input_str = message.command[1] input_str = input_str.replace("@", "") except IndexError: 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) return else: message.reply_text( "❌ **Force Subscribe is disabled in this chat.**") return if input_str.lower() in ("off", "no", "disable"): sql.disapprove(chat_id) message.reply_text( "❌ **Force Subscribe is Disabled Successfully.**") elif input_str: 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 pyrogram.errors.exceptions.bad_request_400.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 pyrogram.errors.exceptions.bad_request_400.UsernameNotOccupied: message.reply_text(f"❗ **Invalid Channel Username.**") except ValueError: message.reply_text(f"❗ **Invalid Channel Username.**") else: message.reply_text("⚠️ **Something went wrong.**") else: message.reply_text( "❗ **Group Creator Required**\n__You have to be the group creator to do that.__" )
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 in Config.SUDO_USERS: channel = chat_db.channel if channel.startswith("-"): url = client.export_chat_invite_link(int(channel)) else: url = f"https://t.me/{channel}" try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( f"Hi {message.from_user.mention}, You Are **Not Subscribed** To My [Channel]({url}) Yet. Please 👉 [Join]({url}) And **Press The Button Below** 👇 To Unmute Yourself..", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("💬 Subscribe", url=url)], [ InlineKeyboardButton( "🔕 UnMute Me", callback_data="onUnMuteRequest") ]])) client.restrict_chat_member( chat_id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit( "❗ **I am not an admin here.**\n__Make me admin with ban user permission and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id) except ChatAdminRequired: client.send_message( chat_id, text= f"❗ **I am not an admin in [channel]({url})**\n__Make me admin in the channel and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id)
def onButtonPress(client, cb): user_id = cb.from_user.id chat_id = cb.message.chat.id cws = sql.fs_settings(chat_id) if cws: channel = cws.channel if client.get_chat_member( chat_id, user_id).restricted_by.id == (client.get_me()).id: try: client.get_chat_member(channel, user_id) client.unban_chat_member(chat_id, user_id) except UserNotParticipant: client.answer_callback_query( cb.id, text="ℹ Join The Channel And Press The Button Again.") else: client.answer_callback_query( cb.id, text="ℹ You Are Muted By Admins For Other Reasons.", show_alert=True)
def config(client, message): user = client.get_chat_member(message.chat.id, message.from_user.id) if user.status is "creator": chat_id = message.chat.id try: input_str = message.command[1] input_str = input_str.replace("@", "") except IndexError: if sql.fs_settings(chat_id): message.reply_text( f"Force Subscribe is **enabled** in this chat.\nChannel - @{sql.fs_settings(chat_id).channel}" ) return else: message.reply_text( "Force Subscribe is **disabled** in this chat.") return if input_str.lower() in ("off", "no", "disable"): sql.disapprove(chat_id) message.reply_text("Force Subscribe is **Disabled**") elif input_str: try: client.get_chat_member(input_str, "me") sql.add_channel(chat_id, input_str) message.reply_text( f"Force Subscribe is **enabled** for this chat\nChannel - @{input_str}" ) except pyrogram.errors.exceptions.bad_request_400.UserNotParticipant: message.reply_text( f"I am not an admin in @{input_str}\nAdd me on your channel as admin and send the command again." ) except pyrogram.errors.exceptions.bad_request_400.UsernameNotOccupied: message.reply_text(f"Invalid Channel Username") except ValueError: message.reply_text( f"@{input_str} didn't belongs to a channel.") else: message.reply_text("Something went wrong") else: message.reply_text("You have to be the **Group Creator** to do that.")
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 in Config.SUDO_USERS: channel = chat_db.channel try: client.get_chat_member(channel, user_id) except UserNotParticipant: try: sent_message = message.reply_text( " рдирд╛рдо тЮ│ {}\nрдЖрдкрдиреЗ рд╣рдорд╛рд░реЗ **[CHANNEL](https://t.me/{})** рдХреЛ JOIN рдирд╣реАрдВ рдХрд┐рдпрд╛ рд╣реИ \n\nрдХреГрдкрдпрд╛ рдЗрд╕ ЁЯСЙ **@{}** рдХреЛ JOIN рдХрд░ рд▓реЗрдВ \n\nрдФрд░ рдиреАрдЪреЗ рджрд┐рдпреЗ рдЧрдП **UNMUTE ME** ЁЯСЗ рдмрдЯрди рдкрд░ CLICK рдХрд░реЗрдВред ЁЯСЗ" .format(message.from_user.mention, channel, channel), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(inline_keyboard=[[ InlineKeyboardButton( "UNMUTE MEЁЯФХ", callback_data="onUnMuteRequest") ] + [ InlineKeyboardButton("JOIN HEREЁЯФФ", url="t.me/{}".format(channel)) ]])) client.restrict_chat_member( chat_id, user_id, ChatPermissions(can_send_messages=False)) except ChatAdminRequired: sent_message.edit( "тЭЧ **I am not an admin here.**\n__Make me admin with ban user permission and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id) except ChatAdminRequired: client.send_message( chat_id, text= f"тЭЧ **I am not an admin in @{channel}**\n__Make me admin in the channel and add me again.\n#Leaving this chat...__" ) client.leave_chat(chat_id)
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) if cb.message.reply_to_message.from_user.id == user_id: cb.message.delete() except UserNotParticipant: client.answer_callback_query( cb.id, text= "❗ Silahkan join 'channel' dan tekan tombol 'UnMute Me'.", show_alert=True) else: client.answer_callback_query( cb.id, text="❗ Kamu di mute karena alasan lain.", 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...__" ) client.leave_chat(chat_id) else: client.answer_callback_query( cb.id, text= "❗ Warning: Jangan klik kalau kamu tidak sedang di mute.", show_alert=True)
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) if cb.message.reply_to_message.from_user.id == user_id: cb.message.delete() except UserNotParticipant: client.answer_callback_query( cb.id, text= "❗ Bergabunglah dengan 'channel' yang disebutkan dan tekan tombol 'Suarakan Saya' Lagi", show_alert=True) else: client.answer_callback_query( cb.id, text="❗ Anda dibisukan oleh admin karena alasan lain.", 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} sedang mencoba menyuarakan tetapi saya tidak dapat mensuarakannya karena saya bukan admin dalam obrolan ini, tambahkan saya sebagai admin lagi.**\n__#Leaving this chat...__" ) client.leave_chat(chat_id) else: client.answer_callback_query( cb.id, text= "❗ Peringatan: Jangan klik tombol suarakan saya jika Anda dapat berbicara dengan bebas.", show_alert=True)
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) if cb.message.reply_to_message.from_user.id == user_id: cb.message.delete() except UserNotParticipant: client.answer_callback_query( cb.id, text= "❗ Join our channel @checkedplugins and press the 'Let Me Speak' button again.", show_alert=True) else: client.answer_callback_query( cb.id, text="❗ You are muted by admins for other reasons.", 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...__" ) client.leave_chat(chat_id) else: client.answer_callback_query( cb.id, text= "❗ Warning: DON'T Try to act smart \nI already unmuted you.", show_alert=True)
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) if cb.message.reply_to_message.from_user.id == user_id: cb.message.delete() except UserNotParticipant: client.answer_callback_query( cb.id, text= "❗ sub 'channel' kemudian klik 'UnMute Me' buat bisa ngetik.", show_alert=True) else: client.answer_callback_query( cb.id, text="❗ You are muted by admins for other reasons.", 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...__" ) client.leave_chat(chat_id) else: client.answer_callback_query( cb.id, text= "❗ Warning: Don't click the button if you can speak freely.", show_alert=True)
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) if cb.message.reply_to_message.from_user.id == user_id: cb.message.delete() except UserNotParticipant: client.answer_callback_query( cb.id, text= f"❗ අපේ @{channel} channel එකට Join වෙලා 'UnMute Me' button එක ආපහු ඔබන්න.", show_alert=True) else: client.answer_callback_query( cb.id, text="❗ ඔයාව වෙන හේතුවක් නිසා Admin ල mute කරලයි ඉන්නෙ.", 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...__" ) client.leave_chat(chat_id) else: client.answer_callback_query( cb.id, text= "❗ අවවාදයයි: ඔයාට කතාකරන්න පුලුවන්කම තියෙද්දි button එක click කරන්න එපා.", show_alert=True)
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) if cb.message.reply_to_message.from_user.id == user_id: cb.message.delete() except UserNotParticipant: client.answer_callback_query( cb.id, text= "❗ Join the Mentioned 'Channel' and Press The 'UnMute Me' Button Again.", show_alert=True) else: client.answer_callback_query( cb.id, text="❗ You Are Muted By Admins For Other Reasons.", 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...__" ) client.leave_chat(chat_id) else: client.answer_callback_query( cb.id, text= "❗ Warning: Don't Click The Button If You Can Text Freely.", show_alert=True)