diff --git a/Config.py b/Config.py index 2166cf30..b53bed1f 100644 --- a/Config.py +++ b/Config.py @@ -6,3 +6,8 @@ class Config(object): BOT_TOKEN = os.environ.get("BOT_TOKEN", "") STRING_SESSION = os.environ.get("STRING_SESSION", "") HEROKU_MODE = os.environ.get("HEROKU_MODE", None) + BOT_USERNAME = os.environ.get("BOT_USERNAME", "Zaid2_Robot") + SUPPORT = os.environ.get("SUPPORT", "TheSupportChat") + CHANNEL = os.environ.get("CHANNEL", "TheUpdatesChannel") + START_IMG = os.environ.get("START_IMG", "https://telegra.ph/file/35a7b5d9f1f2605c9c0d3.png") + CMD_IMG = os.environ.get("CMD_IMG", "https://telegra.ph/file/66518ed54301654f0b126.png") diff --git a/Dockerfile b/Dockerfile index b75039f7..559c6b7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,4 @@ RUN npm i -g npm COPY . /app/ WORKDIR /app/ RUN pip3 install -U -r requirements.txt -CMD python3 -m Zaid +CMD bash start diff --git a/README.md b/README.md index 925c6e47..562c593a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # Telethon-Music +# + +
𝐆𝐞𝐧𝐞𝐫𝐚𝐭𝐞 𝐒𝐭𝐫𝐢𝐧𝐠 𝐒𝐞𝐬𝐬𝐢𝐨𝐧
+ + + ## ᴅᴇᴘʟᴏʏ Note: This Code Based On Telethon So You need [Telethon String Session](https://replit.com/@Itz-zaid/Generator) And A bot token from @botfather @@ -14,15 +20,10 @@ Note: This Code Based On Telethon So You need [Telethon String Session](https://- ## ᴅᴇᴘʟᴏʏ ᴏɴ ʀᴀɪʟᴡᴀʏ 🚄 ꜰᴏʀ ᴅᴇᴘʟᴏʏ ᴏɴ ʀᴀɪʟᴡᴀʏ ᴍᴀᴋᴇ [Necessary Variables in config], ᴜ ʜᴀᴠᴇ ᴛᴏ ꜰɪʟʟ. -
+ ## Local Deployment Process ```sh diff --git a/Zaid/__init__.py b/Zaid/__init__.py index 4bd783b7..04d37bf5 100644 --- a/Zaid/__init__.py +++ b/Zaid/__init__.py @@ -13,6 +13,7 @@ from Config import Config +BOT_USERNAME = Config.BOT_USERNAME bot = TelegramClient('Zaid', api_id=Config.API_ID, api_hash=Config.API_HASH) Zaid = bot.start(bot_token=Config.BOT_TOKEN) diff --git a/Zaid/plugins/admins.py b/Zaid/plugins/admins.py new file mode 100644 index 00000000..bbc48f95 --- /dev/null +++ b/Zaid/plugins/admins.py @@ -0,0 +1,107 @@ +from telethon import events, Button +from Zaid import Zaid +from Zaid.status import * +from telethon.tl.functions.channels import EditAdminRequest +from telethon.tl.types import ChatAdminRights +from telethon.tl.functions.users import GetFullUserRequest +from telethon.tl.functions.messages import ExportChatInviteRequest + +@Zaid.on(events.callbackquery.CallbackQuery(data="admin")) +async def _(event): + + await event.edit(ADMIN_TEXT, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]]) + +@Zaid.on(events.callbackquery.CallbackQuery(data="play")) +async def _(event): + + await event.edit(PLAY_TEXT, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]]) + +@Zaid.on(events.NewMessage(pattern="^[!?/]promote ?(.*)")) +@is_admin +async def promote(event, perm): + if event.is_private: + await event.reply("This cmd is made to be used in groups, not in PM!") + return + + if not perm.add_admins: + await event.reply("You are missing the following rights to use this command:CanAddAdmins!") + return + input_str = event.pattern_match.group(1) + user = await event.get_reply_message() + if not input_str and not user: + await event.reply("Reply to a user or give its username to promote him!") + return + sed = await Zaid(GetFullUserRequest(id=user.sender_id or input_str)) + await Stark(EditAdminRequest(event.chat_id, user.sender_id or input_str, ChatAdminRights( + add_admins=False, + invite_users=True, + change_info=False, + ban_users=True, + delete_messages=True, + pin_messages=True), rank="Admin")) + + if not input_str: + await event.reply(f"Successfully Promoted [{sed.user.first_name}](tg://user?id={user.sender_id}) in {event.chat.title}!") + return + + await event.reply(f"Succesfully Promoted {input_str} in {event.chat.title}") + +@Zaid.on(events.NewMessage(pattern="^[!?/]demote ?(.*)")) +@is_admin +async def promote(event, perm): + if event.is_private: + await event.reply("This cmd is made to be used in groups, not in PM!") + return + if not perm.add_admins: + await event.reply("You are missing the following rights to use this command:CanAddAdmins!") + return + input_str = event.pattern_match.group(1) + user = await event.get_reply_message() + if not input_str and not user: + await event.reply("Reply to a user or give its username to demote him!") + return + sed = await Zaid(GetFullUserRequest(id=user.sender_id or input_str)) + await Stark(EditAdminRequest(event.chat_id, user.sender_id or input_str, ChatAdminRights( + add_admins=False, + invite_users=None, + change_info=None, + ban_users=None, + delete_messages=None, + pin_messages=None), rank="Not Admin")) + + if not input_str: + await event.reply(f"Successfully Demoted [{sed.user.first_name}](tg://user?id={user.sender_id}) in {event.chat.title}!") + return + + await event.reply(f"Succesfully Demoted {input_str} in {event.chat.title}") + + +@Zaid.on(events.NewMessage(pattern="^[!?/]invitelink")) +async def invitelink(event): + + if event.is_private: + await event.reply("This cmd is made to be used in groups, not in PM!") + return + link = await Zaid(ExportChatInviteRequest(event.chat_id)) + await event.reply(f"Group link of {event.chat.title} is [here]({link.link})", link_preview=False) + +ADMIN_TEXT = """ +**✘ A module from which admins of the chat can use!** + +‣ `?promote` - To Promote a user in the chat. +‣ `?demote` - To Demote a user in the chat. +‣ `?invitelink` - To get invitelink of a chat. +‣ `?end` - To End music streaming. +‣ `?skip` - To Skip Tracks Going on. +‣ `?pause` - To Pause streaming. +‣ `?resume` - to Resume Streaming. +‣ `?leavevc` - force The Userbot to leave Vc Chat (Sometimes Joined). +‣ `?playlist` - to check playlists. +""" + +PLAY_TEXT = """ +**✘ A module from which users of the chat can use!** + +‣ `?play` - To Play Audio from Else Reply to audio file. +‣ `?vplay` - To Stream Videos (HEROKU_MODE > Doesn't support). +""" diff --git a/Zaid/plugins/bans.py b/Zaid/plugins/bans.py new file mode 100644 index 00000000..b72c00a0 --- /dev/null +++ b/Zaid/plugins/bans.py @@ -0,0 +1,172 @@ +from Zaid import Zaid +from Zaid.status import * +from telethon import events, Button +from telethon.tl.functions.channels import EditBannedRequest +from telethon.tl.types import ChatBannedRights + +BANS_TEXT = """ +**✘ Some people need to be publicly banned; spammers, annoyances, or just trolls.** + +‣ `?kickme` - To self Kick you from a chat. +‣ `?kick` - To kick someone from a chat. +‣ `?unban` - To unban a member from the chat. +‣ `?ban` - To Ban Someone from a chat. +‣ `?dban` - To delete the replied msg and bans the user. +‣ `?sban` - To delete the replied msg and kicks the user. +‣ `?skick` - To Delete Your msg and kicks the user +‣ `?dkick` - To delete your msg and and kicks the replied user. +""" + +@Zaid.on(events.NewMessage(pattern="^[!?/]kick ?(.*)")) +@is_admin +async def kick(event, perm): + + if event.is_private: + await event.reply("This cmd is made to be used in groups not PM") + return + if not perm.ban_users: + await event.reply("You are missing the following rights to use this command:CanBanUsers!") + return + input_str = event.pattern_match.group(1) + msg = await event.get_reply_message() + if not input_str and not msg: + await event.reply("Reply to a user or give its username to kick him") + return + + replied_user = msg.sender_id + us = msg.sender.username + info = await Zaid.get_entity(us) + await Zaid.kick_participant(event.chat_id, input_str or replied_user) + await event.reply(f"Succesfully Kicked [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}") + +@Zaid.on(events.NewMessage(pattern="^[!?/]kickme")) +async def kickme(event): + + if event.is_private: + await event.reply("This cmd is made to be used in groups not PM") + return + + check = await Zaid.get_permissions(event.chat_id, event.sender_id) + if check.is_admin: + await event.reply("Sorry but I can't kick admins!") + return + + await event.reply("Ok, as your wish") + await Zaid.kick_participant(event.chat_id, event.sender_id) + +@Zaid.on(events.NewMessage(pattern="^[!?/]ban ?(.*)")) +@is_admin +async def ban(event, perm): + if event.is_private: + await event.reply("This cmd is made to be used in groups not PM") + return + if not perm.ban_users: + await event.reply("You are missing the following rights to use this command:CanBanUsers!") + return + input_str = event.pattern_match.group(1) + msg = await event.get_reply_message() + if not input_str and not msg: + await event.reply("Reply to a user or give its username to ban him") + return + replied_user = msg.sender_id + us = msg.sender.username + info = await Zaid.get_entity(us) + await Zaid(EditBannedRequest(event.chat_id, replied_user, ChatBannedRights(until_date=None, view_messages=True))) + await event.reply(f"Succesfully Banned [{info.first_name}](tg://user?id={replied_user}) in {event.chat.title}") + +@Zaid.on(events.NewMessage(pattern="^[!?/]unban ?(.*)")) +@is_admin +async def unban(event, perm): + if event.is_private: + await event.reply("This cmd is made to be used in groups not PM") + return + if not perm.ban_users: + await event.reply("You are missing the following rights to use this command:CanBanUsers!") + return + input_str = event.pattern_match.group(1) + msg = await event.get_reply_message() + if not input_str and not msg: + await event.reply("Reply to a user or give its username to unban him") + return + replied_user = msg.sender_id + us = msg.sender.username + info = await Zaid.get_entity(us) + await Zaid(EditBannedRequest(event.chat_id, replied_user, ChatBannedRights(until_date=None, view_messages=False))) + await event.reply(f"Succesfully Unbanned [{info.first_name}](tg://user?id={replied_user}) in {event.chat.title}") + +@Zaid.on(events.NewMessage(pattern="^[!?/]skick")) +@is_admin +async def skick(event, perm): + if not perm.ban_users: + await event.reply("You are missing the following rights to use this command:CanBanUsers!") + return + reply_msg = await event.get_reply_message() + if not reply_msg: + await event.reply("Reply to someone to delete it and kick the user!") + return + + us = reply_msg.sender.username + info = await Zaid.get_entity(us) + x = (await event.get_reply_message()).sender_id + zx = (await event.get_reply_message()) + await event.delete() + await Zaid.kick_participant(event.chat_id, x) + await event.reply(f"Succesfully Kicked [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}") + +@Zaid.on(events.NewMessage(pattern="^[!?/]dkick")) +@is_admin +async def dkick(event, perm): + if not perm.ban_users: + await event.reply("You are missing the following rights to use this command:CanBanUsers!") + return + reply_msg = await event.get_reply_message() + if not reply_msg: + await event.reply("Reply to someone to delete it and kick the user!") + return + us = reply_msg.sender.username + info = await Zaid.get_entity(us) + x = await event.get_reply_message() + await x.delete() + await Zaid.kick_participant(event.chat_id, x.sender_id) + await event.reply(f"Succesfully Kicked [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}") + +@Zaid.on(events.NewMessage(pattern="^[!?/]dban")) +@is_admin +async def dban(event, perm): + if not perm.ban_users: + await event.reply("You are missing the following rights to use this command:CanBanUsers!") + return + reply_msg = await event.get_reply_message() + if not reply_msg: + await event.reply("Reply to someone to delete the message and ban the user!") + return + us = reply_msg.sender.username + info = await Zaid.get_entity(us) + x = (await event.get_reply_message()).sender_id + zx = (await event.get_reply_message()) + await zx.delete() + await Zaid(EditBannedRequest(event.chat_id, x, ChatBannedRights(until_date=None, view_messages=True))) + await event.reply("Successfully Banned!") + await event.reply(f"Succesfully Banned [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}") + +@Zaid.on(events.NewMessage(pattern="^[!?/]sban")) +@is_admin +async def sban(event, perm): + if not perm.ban_users: + await event.reply("You are missing the following rights to use this command:CanBanUsers!") + return + reply_msg = await event.get_reply_message() + if not reply_msg: + await event.reply("Reply to someone to delete the message and ban the user!") + return + us = reply_msg.sender.username + info = await Zaid.get_entity(us) + x = (await event.get_reply_message()).sender_id + zx = (await event.get_reply_message()) + await event.delete() + await Zaid(EditBannedRequest(event.chat_id, x, ChatBannedRights(until_date=None, view_messages=True))) + await event.reply(f"Succesfully Banned [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}") + +@Zaid.on(events.callbackquery.CallbackQuery(data="bans")) +async def banhelp(event): + await event.edit(BANS_TEXT, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]]) diff --git a/Zaid/plugins/help.py b/Zaid/plugins/help.py new file mode 100644 index 00000000..914cd8db --- /dev/null +++ b/Zaid/plugins/help.py @@ -0,0 +1,32 @@ +from telethon import events, Button +from Zaid import Zaid, BOT_USERNAME + +btn =[ + [Button.inline("Admin", data="admin"), Button.inline("Bans", data="bans")], + [Button.inline("Pins", data="pins"), Button.inline("Pugres", data="purges")], + [Button.inline("Play", data="play"), Button.inline("Chat Cleaner", data="zombies")], + [Button.inline("Locks", data="locks"), Button.inline("Misc", data="misc")], + [Button.inline("Home", data="start")]] + +HELP_TEXT = "Welcome To help Menu Section\n\nClick on the Buttons!" + + +@Zaid.on(events.NewMessage(pattern="[!?/]help")) +async def help(event): + + if event.is_group: + await event.reply("Contact me in PM to get available help menu!", buttons=[ + [Button.url("Help And Commands!", "t.me/{}?start=help".format(BOT_USERNAME))]]) + return + + await event.reply(HELP_TEXT, buttons=btn) + +@Zaid.on(events.NewMessage(pattern="^/start help")) +async def _(event): + + await event.reply(HELP_TEXT, buttons=btn) + +@Zaid.on(events.callbackquery.CallbackQuery(data="help")) +async def _(event): + + await event.edit(HELP_TEXT, buttons=btn) diff --git a/Zaid/plugins/info.py b/Zaid/plugins/info.py new file mode 100644 index 00000000..0e2953f3 --- /dev/null +++ b/Zaid/plugins/info.py @@ -0,0 +1,74 @@ +from telethon import events, Button, types +from Zaid import Zaid +from Zaid.status import * +from telethon.tl.types import ChannelParticipantsAdmins +from datetime import timedelta +from telethon.tl.functions.photos import GetUserPhotosRequest as P +from telethon.tl.functions.users import GetFullUserRequest + + +MISC_HELP = """ +**✘ An "odds and ends" module for small, simple commands which don't really fit anywhere.** + +‣ `?id` - To get current chat id or replied user id. +‣ `?info` - To get info of a user. +""" + +@Zaid.on(events.NewMessage(pattern="^[!?/]id")) +async def id(event): + + if event.is_private: + await event.reply(f"Your id is `{event.sender_id}`.") + return + + ID = """ +**Chat-ID:** `{}` +**User-ID:** `{}` +""" + + msg = await event.get_reply_message() + if not msg: + await event.reply(ID.format(event.chat_id, event.sender_id)) + return + + await event.reply(f"User {msg.sender.first_name} id is `{msg.sender_id}`.") + +@Zaid.on(events.NewMessage(pattern="^[!?/]info ?(.*)")) +async def info(event): + + sed = await Zaid(P(user_id=event.sender_id, offset=42, max_id=0, limit=80)) + hn = await Zaid(GetFullUserRequest(event.sender_id)) + text = "**✘ UserInfo:**\n\n" + text += "**» Fɪʀsᴛ Nᴀᴍᴇ:** {}\n" + text += "**» Lᴀsᴛ Nᴀᴍᴇ:** {}\n" + text += "**» Usᴇʀ-ID:** `{}`\n" + text += "**» Usᴇʀɴᴀᴍᴇ:** @{}\n" + text += "**» Nᴏ. Oғ Pғᴘs:** `{}`\n" + text += "**» Usᴇʀ-Bɪᴏ:** `{}`\n" + text += "**» PᴇʀᴍᴀLɪɴᴋ:** [Link](tg://user?id={})\n" + + input_str = event.pattern_match.group(1) + if not input_str: + await Zaid.send_message(event.chat_id, text.format(hn.user.first_name, hn.user.last_name, event.sender_id, event.sender.username, sed.count, hn.about, event.sender_id)) + return + + input_str = event.pattern_match.group(1) + ha = await Zaid.get_entity(input_str) + hu = await Zaid(GetFullUserRequest(id=input_str)) + sedd = await Zaid(P(user_id=input_str, offset=42, max_id=0, limit=80)) + + textn = "**✘ UserInfo:**\n\n" + textn += "**» Fɪʀsᴛ Nᴀᴍᴇ:** {}\n" + textn += "**» Lᴀsᴛ Nᴀᴍᴇ:** {}\n" + textn += "**» Usᴇʀ-ID:** `{}`\n" + textn += "**» Usᴇʀɴᴀᴍᴇ:** @{}\n" + textn += "**» Nᴏ. Oғ Pғᴘs:** `{}`\n" + textn += "**» Usᴇʀ-Bɪᴏ:** `{}`\n" + textn += "**» PᴇʀᴍᴀLɪɴᴋ:** [Link](tg://user?id={})\n" + + await event.reply(textn.format(ha.first_name, ha.last_name, ha.id, ha.username, sedd.count, hu.about, ha.id)) + + +@Zaid.on(events.callbackquery.CallbackQuery(data="misc")) +async def _(event): + await event.edit(MISC_HELP, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]]) diff --git a/Zaid/plugins/locks.py b/Zaid/plugins/locks.py new file mode 100644 index 00000000..477ecfa3 --- /dev/null +++ b/Zaid/plugins/locks.py @@ -0,0 +1,133 @@ +from telethon import events, Button, types +from Zaid import Zaid +from Zaid.status import * + +LOCKS_HELP = """ +**✘ Do stickers annoy you? or want to avoid people sharing links? or pictures? You're in the right place!** + +‣ `?lock` - To lock a module in the chat. +‣ `?unlock` - To unlock a module in the chat. +‣ `?locktypes` - To get a list of modules can be locked +""" + +@Zaid.on(events.NewMessage(pattern="^[!?/]lock ?(.*)")) +@is_admin +async def lock(event, perm): + if not perm.change_info: + await event.reply("You are missing the following rights to use this command:CanChangeInfo") + return + input_str = event.pattern_match.group(1) + if not input_str: + await event.reply("You haven't specified anything to lock.") + return + if "text" in input_str: + await Stark.edit_permissions(event.chat_id, send_messages=False) + await event.reply("Locked `text`.") + elif "media" in input_str: + await Stark.edit_permissions(event.chat_id, send_media=False) + await event.reply("Locked `media`.") + elif "sticker" in input_str: + await Stark.edit_permissions(event.chat_id, send_stickers=False) + await event.reply("Locked `sticker`.") + elif "gifs" in input_str: + await Stark.edit_permissions(event.chat_id, send_gifs=False) + await event.reply("Locked `gifs`.") + elif "forward" in input_str: + await Stark.edit_permissions(event.chat_id, forwards=False) + await event.reply("Locked `forward`.") + elif "games" in input_str: + await Stark.edit_permissions(event.chat_id, send_games=False) + await event.reply("Locked `games`.") + elif "inline" in input_str: + await Stark.edit_permissions(event.chat_id, send_inline=False) + await event.reply("Locked `inline`.") + elif "polls" in input_str: + await Stark.edit_permissions(event.chat_id, send_polls=False) + await event.reply("Locked `polls`.") + elif "preview" in input_str: + await Stark.edit_permissions(event.chat_id, embed_link_previews=False) + await event.reply("Locked `preview`.") + elif "all" in input_str: + await Zaid.edit_permissions(event.chat_id, + send_messages=False, + send_media=False, + send_stickers=False, + send_gifs=False, + send_games=False, + send_inline=False, + send_polls=False, + embed_link_previews=False) + await event.reply("Locked `all`.") + + +@Zaid.on(events.NewMessage(pattern="^[!?/]unlock ?(.*)")) +@is_admin +async def unlock(event, perm): + if not perm.change_info: + await event.reply("You are missing the following rights to use this command:CanChangeInfo") + return + input_str = event.pattern_match.group(1) + if not input_str: + await event.reply("You haven't specified anything to unlock.") + return + if "text" in input_str: + await Stark.edit_permissions(event.chat_id, send_messages=True) + await event.reply("Unlocked `text`.") + elif "media" in input_str: + await Stark.edit_permissions(event.chat_id, send_media=True) + await event.reply("Unlocked `media`.") + elif "sticker" in input_str: + await Stark.edit_permissions(event.chat_id, send_stickers=True) + await event.reply("Unlocked `sticker`.") + elif "gifs" in input_str: + await Stark.edit_permissions(event.chat_id, send_gifs=True) + await event.reply("Unlocked `gifs`.") + elif "forward" in input_str: + await Stark.edit_permissions(event.chat_id, forwards=True) + await event.reply("Unlocked `forward`.") + elif "games" in input_str: + await Stark.edit_permissions(event.chat_id, send_games=True) + await event.reply("Unlocked `games`.") + elif "inline" in input_str: + await Stark.edit_permissions(event.chat_id, send_inline=True) + await event.reply("Unlocked `inline`.") + elif "polls" in input_str: + await Stark.edit_permissions(event.chat_id, send_polls=True) + await event.reply("Unlocked `polls`.") + elif "preview" in input_str: + await Stark.edit_permissions(event.chat_id, embed_link_previews=True) + await event.reply("Unlocked `preview`.") + elif "all" in input_str: + await Zaid.edit_permissions(event.chat_id, + send_messages=True, + send_media=True, + send_stickers=True, + send_gifs=True, + send_games=True, + send_inline=True, + send_polls=True, + embed_link_previews=True) + await event.reply("Unlocked `all`.") + + +@Zaid.on(events.NewMessage(pattern="^[!?/]locktypes")) +async def locktypes(event): + TEXT = """ +**Locks:** + +‣ Text +‣ Media +‣ Sticker +‣ Gifs +‣ Videos +‣ Contacts +‣ Games +‣ Inline +‣ all +""" + await event.reply(TEXT) + +@Zaid.on(events.callbackquery.CallbackQuery(data="locks")) +async def _(event): + + await event.edit(LOCKS_HELP, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]]) diff --git a/Zaid/plugins/pins.py b/Zaid/plugins/pins.py new file mode 100644 index 00000000..801d4a44 --- /dev/null +++ b/Zaid/plugins/pins.py @@ -0,0 +1,104 @@ +from telethon import events, Button, types +from Zaid import Zaid +from Zaid.status import * + +PINS_TEXT = """ +**✘ All the pin related commands can be found here; keep your chat up to date on the latest news with a simple pinned message!** + +‣ `?pin` - To pinned a reply msg. +‣ `?unpin` - To Unpin the latest pinned msg. +‣ `?unpinall` - To unpinall all pinned msgs at once. +‣ `?pinned` - To get current pinned msg. + +**➥Note:** __Add `notify` after ?pin to notify all chat members.__ +""" + +@Zaid.on(events.NewMessage(pattern="^[?!/]pinned")) +async def get_pinned(event): + chat_id = (str(event.chat_id)).replace("-100", "") + + Ok = await Zaid.get_messages(event.chat_id, ids=types.InputMessagePinned()) + tem = f"The pinned message in {event.chat.title} is here." + await event.reply(tem, parse_mode="html", link_preview=False) + +@Zaid.on(events.NewMessage(pattern="^[!?/]pin ?(.*)")) +@is_admin +async def pin(event, perm): + if not perm.pin_messages: + await event.reply("You are missing the following rights to use this command:CanPinMsgs.") + return + msg = await event.get_reply_message() + if not msg: + await event.reply("Reply to a msg to pin it!") + return + input_str = event.pattern_match.group(1) + if "notify" in input_str: + await Zaid.pin_message(event.chat_id, msg, notify=True) + return + await Zaid.pin_message(event.chat_id, msg) + +@Zaid.on(events.NewMessage(pattern="^[!?/]unpin ?(.*)")) +@is_admin +async def unpin(event, perm): + if not perm.pin_messages: + await event.reply("You are missing the following rights to use this command:CanPinMsgs.") + return + chat_id = (str(event.chat_id)).replace("-100", "") + ok = await Zaid.get_messages(event.chat_id, ids=types.InputMessagePinned()) + await Stark.unpin_message(event.chat_id, ok) + await event.reply(f"Successfully unpinned [this](t.me/{event.chat.username}/{ok.id}) message.", link_preview=False) + +@Zaid.on(events.NewMessage(pattern="^[!?/]permapin")) +@is_admin +async def permapin(event, perm): + if not perm.pin_messages: + await event.reply("You are missing the following rights to use this command:CanPinMsgs.") + return + msg = await event.get_reply_message() + if not msg: + await event.reply("Reply to a msg to permapin it.") + return + hn = await Zaid.send_message(event.chat_id, msg.message) + await Zaid.pin_message(event.chat_id, hn, notify=True) + + +@Zaid.on(events.NewMessage(pattern="^[!?/]unpinall")) +async def unpinall(event, perm): + if not perm.pin_messages: + await event.reply("You are missing the following rights to use this command:CanPinMsgs!") + return + UNPINALL = """ +Are you sure you want to +unpin all msgs? +This action can't be undone! +""" + + await Zaid.send_message(event.chat_id, UNPINALL, buttons=[ + [Button.inline("Confirm", data="unpin")], + [Button.inline("Cancel", data="cancel")]]) + +@Zaid.on(events.callbackquery.CallbackQuery(data="unpin")) +async def confirm(event): + check = await event.client.get_permissions(event.chat_id, event.sender_id) + if check.is_creator: + await Zaid.unpin_message(event.chat_id) + await event.edit("Unpinned All Msgs!") + return + + await event.answer("Group Creator Required!") + +@Zaid.on(events.callbackquery.CallbackQuery(data="cancel")) +async def cancel(event): + + check = await event.client.get_permissions(event.chat_id, event.sender_id) + if check.is_creator: + await event.edit("Unpinning of all msgs has been cancelled!") + return + + await event.answer("Group Creator Required!") + + +@Zaid.on(events.callbackquery.CallbackQuery(data="pins")) +async def _(event): + + await event.edit(PINS_TEXT, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]]) diff --git a/Zaid/plugins/audio.py b/Zaid/plugins/play.py similarity index 94% rename from Zaid/plugins/audio.py rename to Zaid/plugins/play.py index bd801d45..be94e932 100644 --- a/Zaid/plugins/audio.py +++ b/Zaid/plugins/play.py @@ -25,8 +25,8 @@ from youtubesearchpython import VideosSearch -fotoplay = "https://telegra.ph/file/fbdff93b72dac4e43a9af.png" -ngantri = "https://telegra.ph/file/fbdff93b72dac4e43a9af.png" +fotoplay = "https://telegra.ph/file/b6402152be44d90836339.jpg" +ngantri = "https://telegra.ph/file/b6402152be44d90836339.jpg" from Zaid import call_py, Zaid, client as Client owner = "1669178360" from Zaid.helpers.yt_dlp import bash @@ -125,12 +125,12 @@ async def _(event): await event.delete() btnn =[ - [Button.url("💁 Sᴜᴘᴘᴏʀᴛ", url="t.me/TheSupportChat"), Button.url("Cʜᴀɴɴᴇʟ 🙋", url="t.me/TheUpdatesChannel")], + [Button.url("💁 Sᴜᴘᴘᴏʀᴛ", url=f"t.me/{Config.SUPPORT}"), Button.url("Cʜᴀɴɴᴇʟ 🙋", url=f"t.me/{Config.CHANNEL}")], [Button.inline("Cʟᴏꜱᴇ 🗑️", data="cls")]] #play -@Zaid.on(events.NewMessage(pattern="^/play")) +@Zaid.on(events.NewMessage(pattern="^[?!/]play")) async def play(event): title = ' '.join(event.text[5:]) replied = await event.get_reply_message() @@ -147,7 +147,7 @@ async def play(event): or not replied and not title ): - return await event.reply("**Give Me Your Query Which You want to Play**") + return await event.client.send_file(chat_id, Config.CMD_IMG, caption="**Give Me Your Query Which You want to Play**\n\n **Example**: `/play Nira Ishq Bass boosted`", buttons=btnn) elif replied and not replied.audio and not replied.voice or not replied: botman = await event.reply("`Featching Details...`") query = event.text.split(maxsplit=1)[1] @@ -233,7 +233,7 @@ async def play(event): #end -@Zaid.on(events.NewMessage(pattern="^/end")) +@Zaid.on(events.NewMessage(pattern="^[/?!]end")) @is_admin async def vc_end(event, perm): chat_id = event.chat_id @@ -251,7 +251,7 @@ async def vc_end(event, perm): -@Zaid.on(events.NewMessage(pattern="^/vplay")) +@Zaid.on(events.NewMessage(pattern="^[?!/]vplay")) async def vplay(event): if Config.HEROKU_MODE == "ENABLE": await event.reply("__Currently Heroku Mode is ENABLED so You Can't Stream Video because Video Streaming Cause of Banning Your Heroku Account__.") @@ -273,7 +273,7 @@ async def vplay(event): or not replied and not title ): - return await event.reply("**Give Me Your Query Which You Want to stream**") + return await event.client.send_file(chat_id, Config.CMD_IMG, caption="**Give Me Your Query Which You want to Stream**\n\n **Example**: `/vplay Nira Ishq Bass boosted`", buttons=btnn) if replied and not replied.video and not replied.document: xnxx = await event.reply("`Searching Video Details...`") query = event.text.split(maxsplit=1)[1] @@ -414,7 +414,7 @@ async def vplay(event): #playlist -@Zaid.on(events.NewMessage(pattern="^/playlist")) +@Zaid.on(events.NewMessage(pattern="^[?!/]playlist")) @is_admin async def vc_playlist(event, perm): chat_id = event.chat_id @@ -444,7 +444,7 @@ async def vc_playlist(event, perm): #leavevc -@Zaid.on(events.NewMessage(pattern="^/leavevc")) +@Zaid.on(events.NewMessage(pattern="^[?!/]leavevc")) @is_admin async def leavevc(event, perm): xnxx = await event.reply("Processing") @@ -461,7 +461,7 @@ async def leavevc(event, perm): -@Zaid.on(events.NewMessage(pattern="^/skip")) +@Zaid.on(events.NewMessage(pattern="^[?!/]skip")) @is_admin async def vc_skip(event, perm): chat_id = event.chat_id @@ -490,7 +490,7 @@ async def vc_skip(event, perm): await event.reply(DELQUE) -@Zaid.on(events.NewMessage(pattern="^/pause")) +@Zaid.on(events.NewMessage(pattern="^[?!/]pause")) @is_admin async def vc_pause(event, perm): chat_id = event.chat_id @@ -505,7 +505,7 @@ async def vc_pause(event, perm): -@Zaid.on(events.NewMessage(pattern="^/resume")) +@Zaid.on(events.NewMessage(pattern="^[?!/]resume")) @is_admin async def vc_resume(event, perm): chat_id = event.chat_id @@ -542,4 +542,3 @@ async def leftvc(_, chat_id: int): async def kickedvc(_, chat_id: int): if chat_id in QUEUE: clear_queue(chat_id) - diff --git a/Zaid/plugins/purge.py b/Zaid/plugins/purge.py new file mode 100644 index 00000000..56c0770d --- /dev/null +++ b/Zaid/plugins/purge.py @@ -0,0 +1,83 @@ +from telethon import events, Button +from Zaid import Zaid +from Zaid.status import * +import time + +PR_HELP = """ +**✘ Need to delete lots of messages? That's what purges are for!** + +‣ `?purge` - Reply to a msg to delete msgs from there. +‣ `?spurge` - Same as purge, but doesnt send the final confirmation message. +‣ `?del` - Deletes the replied to message. +""" + +@Zaid.on(events.NewMessage(pattern=r"^[?!]purge")) +@is_admin +async def purge_messages(event, perm): + if not perm.delete_messages: + await event.reply("You are missing the following rights to use this command:CanDelMsgs!") + return + start = time.perf_counter() + reply_msg = await event.get_reply_message() + if not reply_msg: + await event.reply( + "Reply to a message to select where to start purging from.") + return + messages = [] + message_id = reply_msg.id + delete_to = event.message.id + + messages.append(event.reply_to_msg_id) + for msg_id in range(message_id, delete_to + 1): + messages.append(msg_id) + if len(messages) == 100: + await event.client.delete_messages(event.chat_id, messages) + messages = [] + + await event.client.delete_messages(event.chat_id, messages) + time_ = time.perf_counter() - start + text = f"Purged in {time_:0.2f} Second(s)" + await event.respond(text, parse_mode='markdown') + +@Zaid.on(events.NewMessage(pattern="^[!?/]spurge")) +@is_admin +async def spurge(event, perm): + if not perm.delete_messages: + await event.reply("You are missing the following rights to use this command:CanDelMsgs!") + return + start = time.perf_counter() + reply_msg = await event.get_reply_message() + if not reply_msg: + await event.reply( + "Reply to a message to select where to start purging from.") + return + messages = [] + message_id = reply_msg.id + delete_to = event.message.id + + messages.append(event.reply_to_msg_id) + for msg_id in range(message_id, delete_to + 1): + messages.append(msg_id) + if len(messages) == 100: + await event.client.delete_messages(event.chat_id, messages) + messages = [] + + await event.client.delete_messages(event.chat_id, messages) + +@Zaid.on(events.NewMessage(pattern="^[!?/]del$")) +@is_admin +async def delete_messages(event, perm): + if not perm.delete_messages: + await event.reply("You are missing the following rights to use this command:CanDelMsgs!") + return + msg = await event.get_reply_message() + if not msg: + await event.reply("Reply to a msg to delete it.") + return + + await msg.delete() + await event.delete() + +@Zaid.on(events.callbackquery.CallbackQuery(data="purges")) +async def _(event): + await event.edit(PR_HELP, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]]) diff --git a/Zaid/plugins/start.py b/Zaid/plugins/start.py index a9b36935..1f9839b3 100644 --- a/Zaid/plugins/start.py +++ b/Zaid/plugins/start.py @@ -1,10 +1,46 @@ -from Zaid import Zaid +from Zaid import Zaid, BOT_USERNAME +from Config import Config from telethon import events, Button -@Zaid.on(events.NewMessage(incoming=True, pattern="/start")) +PM_START_TEXT = """ +ʜᴇʏᴀ! {} +➖➖➖➖➖➖➖➖➖➖➖➖➖➖ +✘ **ɪ'ᴍ ᴀ ꜱɪᴍᴘʟᴇ ᴛᴇʟᴇɢʀᴀᴍ ᴍᴜꜱɪᴄ ᴀɴᴅ ᴍᴀɴᴀɢᴇᴍᴇɴᴛ ʙᴏᴛ**. +‣ **ɪ ᴄᴀɴ ᴘʟᴀʏ ꜱᴏɴɢꜱ ɪɴ ʏᴏᴜʀ ᴠᴏɪᴄᴇ**. +‣ **ɪ ᴄᴀɴ ʙᴀɴ, ᴍᴜᴛᴇ ᴇᴠᴇʀʏ ᴜꜱᴇʀꜱ**. +‣ **ɪ ʜᴀᴠᴇ ᴀʟᴍᴏꜱᴛ ᴀʟʟ ꜰᴇᴀᴛᴜʀᴇꜱ ᴡʜɪᴄʜ ɴᴇᴇᴅꜱ ᴀ ᴍᴜꜱɪᴄ ʙᴏᴛ** +‣ **ᴛʜɪꜱ ʙᴏᴛ ʙᴀꜱᴇᴅ ᴏɴ ᴛᴇʟᴇᴛʜᴏɴ. ꜱᴏ ɪᴛ'ꜱ ᴘʀᴏᴠɪᴅᴇ ᴍᴏʀᴇ ꜱᴛᴀʙɪʟɪᴛʏ ꜰʀᴏᴍ ᴏᴛʜᴇʀ ʙᴏᴛꜱ**! +‣ **ɪ ᴄᴀɴ ᴅᴏ ᴏᴛʜᴇʀ ᴛʜɪɴɢꜱ ʟɪᴋᴇ ᴘɪɴꜱ ᴇᴛᴄꜱ**. +➖➖➖➖➖➖➖➖➖➖➖➖➖➖ +✘ **ᴄʟɪᴄᴋ ᴏɴ ʜᴇʟᴘ ʙᴜᴛᴛᴏɴ 🔘 ꜰᴏʀ ᴍᴏʀᴇ ɪɴꜰᴏʀᴍᴀᴛɪᴏɴ ℹ️**. +""" + +@Zaid.on(events.NewMessage(pattern="^[?!/]start$")) async def start(event): - await event.reply("Hey!\nLet's Try to be a Different \nThis Bot Based on Telethon So it's Stable more.", - buttons=[ - [Button.url("⚙️Support", url="https://t.me/TheSupportChat")], - [Button.url("🤖Repo", url="https://github.com/ITZ-ZAID/Telethon-Music")], - ]) + + if event.is_private: + await event.client.send_file(event.chat_id, + Config.START_IMG, + caption=PM_START_TEXT.format(event.sender.first_name), + buttons=[ + [Button.url("➕ ᴀᴅᴅ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ᴄʜᴀᴛ", f"https://t.me/{BOT_USERNAME}?startgroup=true")], + [Button.url("👨💻 ꜱᴏᴜʀᴄᴇ ᴄᴏᴅᴇ", "https://github.com/ITZ-ZAID/Telethon-Music")], + [Button.url("🗣️ ꜱᴜᴘᴘᴏʀᴛ", f"https://t.me/{Config.SUPPORT}"), Button.url("📣 ᴜᴘᴅᴀᴛᴇꜱ", f"https://t.me/{Config.CHANNEL}")], + [Button.inline("ʜᴇʟᴘ ᴀɴᴅ ᴄᴏᴍᴍᴀɴᴅꜱ", data="help")]]) + return + + if event.is_group: + await event.reply("**ʜᴇʏ! ɪ'ᴍ ꜱᴛɪʟʟ ᴀʟɪᴠᴇ ✅**") + return + + + +@Zaid.on(events.callbackquery.CallbackQuery(data="start")) +async def _(event): + if event.is_private: + await event.edit(PM_START_TEXT.format(event.sender.first_name), buttons=[ + [Button.url("➕ ᴀᴅᴅ ᴍᴇ ᴛᴏ ʏᴏᴜʀ ᴄʜᴀᴛ", f"https://t.me/{BOT_USERNAME}?startgroup=true")], + [Button.url("👨💻 ꜱᴏᴜʀᴄᴇ ᴄᴏᴅᴇ", "https://github.com/ITZ-ZAID/Telethon-Music")], + [Button.url("🗣️ ꜱᴜᴘᴘᴏʀᴛ", f"https://t.me/{Config.SUPPORT}"), Button.url("📣 ᴜᴘᴅᴀᴛᴇꜱ", f"https://t.me/{Config.CHANNEL}")], + [Button.inline("ʜᴇʟᴘ ᴀɴᴅ ᴄᴏᴍᴍᴀɴᴅꜱ", data="help")]]) + return diff --git a/Zaid/plugins/zombies.py b/Zaid/plugins/zombies.py new file mode 100644 index 00000000..e0285724 --- /dev/null +++ b/Zaid/plugins/zombies.py @@ -0,0 +1,93 @@ +from telethon import events, Button +from telethon.errors import ChatAdminRequiredError, UserAdminInvalidError +from telethon.tl.functions.channels import EditBannedRequest +from telethon.tl.types import ChannelParticipantsAdmins, ChatBannedRights +from Zaid import Zaid +from Zaid.status import * + + +CLEANER_HELP = """ +**✘ This is A Module To Remove Deleted Accounts From Your Groups!** + +‣ `?zombies` - To find zombies accounts in your chat. +‣ `?zombies clean` - To remove the deleted accounts from your chat. +""" + + +BANNED_RIGHTS = ChatBannedRights( + until_date=None, + view_messages=True, + send_messages=True, + send_media=True, + send_stickers=True, + send_gifs=True, + send_games=True, + send_inline=True, + embed_links=True, +) + +UNBAN_RIGHTS = ChatBannedRights( + until_date=None, + send_messages=None, + send_media=None, + send_stickers=None, + send_gifs=None, + send_games=None, + send_inline=None, + embed_links=None, +) + + +@Zaid.on(events.NewMessage(pattern="^[!?/]zombies ?(.*)")) +@is_admin +async def clean(event, perm): + if not perm.ban_users: + await event.reply("You don't have enough rights") + return + input_str = event.pattern_match.group(1) + stats = "Group is clean." + deleted = 0 + + if "clean" not in input_str: + zombies = await event.respond("Searching For Zombies/Deleted Accounts...") + async for user in event.client.iter_participants(event.chat_id): + + if user.deleted: + deleted += 1 + if deleted > 0: + stats = f"Found **{deleted}** Zombies In This Group.\ + \nClean Them By Using - `/zombies clean`" + await zombies.edit(stats) + return + + cleaning_zombies = await event.respond("Cleaning Zombies/Deleted Accounts...") + del_u = 0 + del_a = 0 + + async for user in event.client.iter_participants(event.chat_id): + if user.deleted: + try: + await event.client( + EditBannedRequest(event.chat_id, user.id, BANNED_RIGHTS) + ) + except ChatAdminRequiredError: + await cleaning_zombies.edit("I Don't Have Ban Rights In This Group.") + return + except UserAdminInvalidError: + del_u -= 1 + del_a += 1 + await event.client(EditBannedRequest(event.chat_id, user.id, UNBAN_RIGHTS)) + del_u += 1 + + if del_u > 0: + stats = f"Cleaned `{del_u}` Zombies" + + if del_a > 0: + stats = f"Cleaned `{del_u}` Zombies \ + \n`{del_a}` Zombie Admin Accounts Are Not Removed!" + + await cleaning_zombies.edit(stats) + +@Zaid.on(events.callbackquery.CallbackQuery(data="zombies")) +async def _(event): + await event.edit(CLEANER_HELP, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]]) diff --git a/app.json b/app.json index dbd0f080..26c1bd80 100644 --- a/app.json +++ b/app.json @@ -1,12 +1,12 @@ { "name": "Telethon Music Bot", "description": "Music allow you to stream music trought the telegram voice chat feature Based on Telethon.", - "keywords": ["Zaid", "Zaid-Vc-Player", "music", "voice chat", "telegram", "Yukki", "Yukki Music", "Private Music"], + "keywords": ["Zaid", "Zaid-Vc-Player", "music", "voice chat", "telegram", "Yukki", "Yukki Music", "Private Music", telethon], "repository": "https://github.com/ITZ-ZAID/Telethon-Music", "stack": "container", "env": { "STRING_SESSION": { - "description": "fill with the telethon session string from account", + "description": "fill with the telethon session string from https://replit.com/@Itz-zaid/Generator", "required": true }, "HEROKU_MODE": { @@ -24,6 +24,21 @@ "required": false, "value": "4e984ea35f854762dcde906dce426c2d" }, + "SUPPORT": { + "description": "Fill there your group username else leave", + "required": false, + "value": "TheSupportChat" + }, + "CHANNEL": { + "description": "Fill there your Channel username else leave", + "required": false, + "value": "TheUpdatesChannel" + }, + "BOT_USERNAME": { + "description": "Fill there your bot username", + "required": false, + "value": "Zaid2_Robot" + }, "BOT_TOKEN": { "description": "fill with your bot token get from @BotFather on telegram", "required": true, diff --git a/resources/font.ttf b/resources/font.ttf new file mode 100644 index 00000000..3b8622f6 Binary files /dev/null and b/resources/font.ttf differ diff --git a/resources/font2.ttf b/resources/font2.ttf new file mode 100644 index 00000000..2ceaf63a Binary files /dev/null and b/resources/font2.ttf differ diff --git a/start b/start index e9650e8d..e12d57cb 100644 --- a/start +++ b/start @@ -1,4 +1,3 @@ git clone $REPO XYZ cd XYZ -pip3 install -U -r requirements.txt python3 -m Zaid