Skip to content

Commit

Permalink
Merge pull request #4 from ITS-ZAID/main
Browse files Browse the repository at this point in the history
Added Many things
  • Loading branch information
ITZ-ZAID authored Jun 21, 2022
2 parents 7e1c316 + 3eae9c8 commit c9b3f78
Show file tree
Hide file tree
Showing 18 changed files with 885 additions and 31 deletions.
5 changes: 5 additions & 0 deletions Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

# Telethon-Music

#

<p align="center">𝐆𝐞𝐧𝐞𝐫𝐚𝐭𝐞 𝐒𝐭𝐫𝐢𝐧𝐠 𝐒𝐞𝐬𝐬𝐢𝐨𝐧</p>

<p align="center"><a href="https://replit.com/@Itz-zaid/Generator"> <img src="https://img.shields.io/badge/String%20Session-black?style=for-the-badge&logo=replit" width="220" height="38.45"/></a></p>

## ᴅᴇᴘʟᴏʏ

Note: This Code Based On Telethon So You need [Telethon String Session](https://replit.com/@Itz-zaid/Generator) And A bot token from @botfather
Expand All @@ -14,15 +20,10 @@ Note: This Code Based On Telethon So You need [Telethon String Session](https://
<h4>Click the button below to import this code. How to host? Simply import this code then fill your vars in config.py then go to Actions and check build logs!</h4>
<p align="center"><a href="https://github.com/new/import"><img src="https://img.shields.io/badge/Workflow%20Deploy-black?style=for-the-badge&logo=github" width="200""/></a>

## 🚀 Circleci hosting

<h4>Click the button to redirect on circleci Note: First fill your vars in config.py then connect with your GitHub in circleci then deploy!</h4>
<p align="center"><a href="https://circleci.com/"><img src="https://img.shields.io/badge/CircleCi%20Deploy-red?style=for-the-badge&logo=circleci" width="200""/></a>

## ᴅᴇᴘʟᴏʏ ᴏɴ ʀᴀɪʟᴡᴀʏ 🚄
ꜰᴏʀ ᴅᴇᴘʟᴏʏ ᴏɴ ʀᴀɪʟᴡᴀʏ ᴍᴀᴋᴇ [Necessary Variables in config], ᴜ ʜᴀᴠᴇ ᴛᴏ ꜰɪʟʟ.

<p align="center"><a href="https://railway.app/new/template?template=https://github.com/ITZ-ZAID/Telethon-Music/tree/railway&envs=STRING_SESSION,BOT_TOKEN,API_ID,API_HASH"> <img src="https://img.shields.io/badge/Deploy%20To%20Railway-black?style=for-the-badge&logo=railway" width="220" height="38.45"/></a></p>
<p align="center"><a href="https://railway.app/new/template?template=https://github.com/ITZ-ZAID/Telethon-Music/tree/railway&envs=STRING_SESSION,BOT_TOKEN,API_ID,API_HASH,BOT_USERNAME"> <img src="https://img.shields.io/badge/Deploy%20To%20Railway-black?style=for-the-badge&logo=railway" width="220" height="38.45"/></a></p>

## Local Deployment Process
```sh
Expand Down
1 change: 1 addition & 0 deletions Zaid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
107 changes: 107 additions & 0 deletions Zaid/plugins/admins.py
Original file line number Diff line number Diff line change
@@ -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).
"""
172 changes: 172 additions & 0 deletions Zaid/plugins/bans.py
Original file line number Diff line number Diff line change
@@ -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")]])
32 changes: 32 additions & 0 deletions Zaid/plugins/help.py
Original file line number Diff line number Diff line change
@@ -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)
Loading

0 comments on commit c9b3f78

Please sign in to comment.