Skip to content

Commit c9b3f78

Browse files
authored
Merge pull request #4 from ITS-ZAID/main
Added Many things
2 parents 7e1c316 + 3eae9c8 commit c9b3f78

File tree

18 files changed

+885
-31
lines changed

18 files changed

+885
-31
lines changed

Config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ class Config(object):
66
BOT_TOKEN = os.environ.get("BOT_TOKEN", "")
77
STRING_SESSION = os.environ.get("STRING_SESSION", "")
88
HEROKU_MODE = os.environ.get("HEROKU_MODE", None)
9+
BOT_USERNAME = os.environ.get("BOT_USERNAME", "Zaid2_Robot")
10+
SUPPORT = os.environ.get("SUPPORT", "TheSupportChat")
11+
CHANNEL = os.environ.get("CHANNEL", "TheUpdatesChannel")
12+
START_IMG = os.environ.get("START_IMG", "https://telegra.ph/file/35a7b5d9f1f2605c9c0d3.png")
13+
CMD_IMG = os.environ.get("CMD_IMG", "https://telegra.ph/file/66518ed54301654f0b126.png")

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ RUN npm i -g npm
99
COPY . /app/
1010
WORKDIR /app/
1111
RUN pip3 install -U -r requirements.txt
12-
CMD python3 -m Zaid
12+
CMD bash start

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11

22
# Telethon-Music
33

4+
#
5+
6+
<p align="center">𝐆𝐞𝐧𝐞𝐫𝐚𝐭𝐞 𝐒𝐭𝐫𝐢𝐧𝐠 𝐒𝐞𝐬𝐬𝐢𝐨𝐧</p>
7+
8+
<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>
9+
410
## ᴅᴇᴘʟᴏʏ
511

612
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://
1420
<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>
1521
<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>
1622

17-
## 🚀 Circleci hosting
18-
19-
<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>
20-
<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>
21-
2223
## ᴅᴇᴘʟᴏʏ ᴏɴ ʀᴀɪʟᴡᴀʏ 🚄
2324
ꜰᴏʀ ᴅᴇᴘʟᴏʏ ᴏɴ ʀᴀɪʟᴡᴀʏ ᴍᴀᴋᴇ [Necessary Variables in config], ᴜ ʜᴀᴠᴇ ᴛᴏ ꜰɪʟʟ.
2425

25-
<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>
26+
<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>
2627

2728
## Local Deployment Process
2829
```sh

Zaid/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414

1515
from Config import Config
16+
BOT_USERNAME = Config.BOT_USERNAME
1617

1718
bot = TelegramClient('Zaid', api_id=Config.API_ID, api_hash=Config.API_HASH)
1819
Zaid = bot.start(bot_token=Config.BOT_TOKEN)

Zaid/plugins/admins.py

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
from telethon import events, Button
2+
from Zaid import Zaid
3+
from Zaid.status import *
4+
from telethon.tl.functions.channels import EditAdminRequest
5+
from telethon.tl.types import ChatAdminRights
6+
from telethon.tl.functions.users import GetFullUserRequest
7+
from telethon.tl.functions.messages import ExportChatInviteRequest
8+
9+
@Zaid.on(events.callbackquery.CallbackQuery(data="admin"))
10+
async def _(event):
11+
12+
await event.edit(ADMIN_TEXT, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]])
13+
14+
@Zaid.on(events.callbackquery.CallbackQuery(data="play"))
15+
async def _(event):
16+
17+
await event.edit(PLAY_TEXT, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]])
18+
19+
@Zaid.on(events.NewMessage(pattern="^[!?/]promote ?(.*)"))
20+
@is_admin
21+
async def promote(event, perm):
22+
if event.is_private:
23+
await event.reply("This cmd is made to be used in groups, not in PM!")
24+
return
25+
26+
if not perm.add_admins:
27+
await event.reply("You are missing the following rights to use this command:CanAddAdmins!")
28+
return
29+
input_str = event.pattern_match.group(1)
30+
user = await event.get_reply_message()
31+
if not input_str and not user:
32+
await event.reply("Reply to a user or give its username to promote him!")
33+
return
34+
sed = await Zaid(GetFullUserRequest(id=user.sender_id or input_str))
35+
await Stark(EditAdminRequest(event.chat_id, user.sender_id or input_str, ChatAdminRights(
36+
add_admins=False,
37+
invite_users=True,
38+
change_info=False,
39+
ban_users=True,
40+
delete_messages=True,
41+
pin_messages=True), rank="Admin"))
42+
43+
if not input_str:
44+
await event.reply(f"Successfully Promoted [{sed.user.first_name}](tg://user?id={user.sender_id}) in {event.chat.title}!")
45+
return
46+
47+
await event.reply(f"Succesfully Promoted {input_str} in {event.chat.title}")
48+
49+
@Zaid.on(events.NewMessage(pattern="^[!?/]demote ?(.*)"))
50+
@is_admin
51+
async def promote(event, perm):
52+
if event.is_private:
53+
await event.reply("This cmd is made to be used in groups, not in PM!")
54+
return
55+
if not perm.add_admins:
56+
await event.reply("You are missing the following rights to use this command:CanAddAdmins!")
57+
return
58+
input_str = event.pattern_match.group(1)
59+
user = await event.get_reply_message()
60+
if not input_str and not user:
61+
await event.reply("Reply to a user or give its username to demote him!")
62+
return
63+
sed = await Zaid(GetFullUserRequest(id=user.sender_id or input_str))
64+
await Stark(EditAdminRequest(event.chat_id, user.sender_id or input_str, ChatAdminRights(
65+
add_admins=False,
66+
invite_users=None,
67+
change_info=None,
68+
ban_users=None,
69+
delete_messages=None,
70+
pin_messages=None), rank="Not Admin"))
71+
72+
if not input_str:
73+
await event.reply(f"Successfully Demoted [{sed.user.first_name}](tg://user?id={user.sender_id}) in {event.chat.title}!")
74+
return
75+
76+
await event.reply(f"Succesfully Demoted {input_str} in {event.chat.title}")
77+
78+
79+
@Zaid.on(events.NewMessage(pattern="^[!?/]invitelink"))
80+
async def invitelink(event):
81+
82+
if event.is_private:
83+
await event.reply("This cmd is made to be used in groups, not in PM!")
84+
return
85+
link = await Zaid(ExportChatInviteRequest(event.chat_id))
86+
await event.reply(f"Group link of {event.chat.title} is [here]({link.link})", link_preview=False)
87+
88+
ADMIN_TEXT = """
89+
**✘ A module from which admins of the chat can use!**
90+
91+
‣ `?promote` - To Promote a user in the chat.
92+
‣ `?demote` - To Demote a user in the chat.
93+
‣ `?invitelink` - To get invitelink of a chat.
94+
‣ `?end` - To End music streaming.
95+
‣ `?skip` - To Skip Tracks Going on.
96+
‣ `?pause` - To Pause streaming.
97+
‣ `?resume` - to Resume Streaming.
98+
‣ `?leavevc` - force The Userbot to leave Vc Chat (Sometimes Joined).
99+
‣ `?playlist` - to check playlists.
100+
"""
101+
102+
PLAY_TEXT = """
103+
**✘ A module from which users of the chat can use!**
104+
105+
‣ `?play` - To Play Audio from Else Reply to audio file.
106+
‣ `?vplay` - To Stream Videos (HEROKU_MODE > Doesn't support).
107+
"""

Zaid/plugins/bans.py

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
from Zaid import Zaid
2+
from Zaid.status import *
3+
from telethon import events, Button
4+
from telethon.tl.functions.channels import EditBannedRequest
5+
from telethon.tl.types import ChatBannedRights
6+
7+
BANS_TEXT = """
8+
**✘ Some people need to be publicly banned; spammers, annoyances, or just trolls.**
9+
10+
‣ `?kickme` - To self Kick you from a chat.
11+
‣ `?kick` - To kick someone from a chat.
12+
‣ `?unban` - To unban a member from the chat.
13+
‣ `?ban` - To Ban Someone from a chat.
14+
‣ `?dban` - To delete the replied msg and bans the user.
15+
‣ `?sban` - To delete the replied msg and kicks the user.
16+
‣ `?skick` - To Delete Your msg and kicks the user
17+
‣ `?dkick` - To delete your msg and and kicks the replied user.
18+
"""
19+
20+
@Zaid.on(events.NewMessage(pattern="^[!?/]kick ?(.*)"))
21+
@is_admin
22+
async def kick(event, perm):
23+
24+
if event.is_private:
25+
await event.reply("This cmd is made to be used in groups not PM")
26+
return
27+
if not perm.ban_users:
28+
await event.reply("You are missing the following rights to use this command:CanBanUsers!")
29+
return
30+
input_str = event.pattern_match.group(1)
31+
msg = await event.get_reply_message()
32+
if not input_str and not msg:
33+
await event.reply("Reply to a user or give its username to kick him")
34+
return
35+
36+
replied_user = msg.sender_id
37+
us = msg.sender.username
38+
info = await Zaid.get_entity(us)
39+
await Zaid.kick_participant(event.chat_id, input_str or replied_user)
40+
await event.reply(f"Succesfully Kicked [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}")
41+
42+
@Zaid.on(events.NewMessage(pattern="^[!?/]kickme"))
43+
async def kickme(event):
44+
45+
if event.is_private:
46+
await event.reply("This cmd is made to be used in groups not PM")
47+
return
48+
49+
check = await Zaid.get_permissions(event.chat_id, event.sender_id)
50+
if check.is_admin:
51+
await event.reply("Sorry but I can't kick admins!")
52+
return
53+
54+
await event.reply("Ok, as your wish")
55+
await Zaid.kick_participant(event.chat_id, event.sender_id)
56+
57+
@Zaid.on(events.NewMessage(pattern="^[!?/]ban ?(.*)"))
58+
@is_admin
59+
async def ban(event, perm):
60+
if event.is_private:
61+
await event.reply("This cmd is made to be used in groups not PM")
62+
return
63+
if not perm.ban_users:
64+
await event.reply("You are missing the following rights to use this command:CanBanUsers!")
65+
return
66+
input_str = event.pattern_match.group(1)
67+
msg = await event.get_reply_message()
68+
if not input_str and not msg:
69+
await event.reply("Reply to a user or give its username to ban him")
70+
return
71+
replied_user = msg.sender_id
72+
us = msg.sender.username
73+
info = await Zaid.get_entity(us)
74+
await Zaid(EditBannedRequest(event.chat_id, replied_user, ChatBannedRights(until_date=None, view_messages=True)))
75+
await event.reply(f"Succesfully Banned [{info.first_name}](tg://user?id={replied_user}) in {event.chat.title}")
76+
77+
@Zaid.on(events.NewMessage(pattern="^[!?/]unban ?(.*)"))
78+
@is_admin
79+
async def unban(event, perm):
80+
if event.is_private:
81+
await event.reply("This cmd is made to be used in groups not PM")
82+
return
83+
if not perm.ban_users:
84+
await event.reply("You are missing the following rights to use this command:CanBanUsers!")
85+
return
86+
input_str = event.pattern_match.group(1)
87+
msg = await event.get_reply_message()
88+
if not input_str and not msg:
89+
await event.reply("Reply to a user or give its username to unban him")
90+
return
91+
replied_user = msg.sender_id
92+
us = msg.sender.username
93+
info = await Zaid.get_entity(us)
94+
await Zaid(EditBannedRequest(event.chat_id, replied_user, ChatBannedRights(until_date=None, view_messages=False)))
95+
await event.reply(f"Succesfully Unbanned [{info.first_name}](tg://user?id={replied_user}) in {event.chat.title}")
96+
97+
@Zaid.on(events.NewMessage(pattern="^[!?/]skick"))
98+
@is_admin
99+
async def skick(event, perm):
100+
if not perm.ban_users:
101+
await event.reply("You are missing the following rights to use this command:CanBanUsers!")
102+
return
103+
reply_msg = await event.get_reply_message()
104+
if not reply_msg:
105+
await event.reply("Reply to someone to delete it and kick the user!")
106+
return
107+
108+
us = reply_msg.sender.username
109+
info = await Zaid.get_entity(us)
110+
x = (await event.get_reply_message()).sender_id
111+
zx = (await event.get_reply_message())
112+
await event.delete()
113+
await Zaid.kick_participant(event.chat_id, x)
114+
await event.reply(f"Succesfully Kicked [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}")
115+
116+
@Zaid.on(events.NewMessage(pattern="^[!?/]dkick"))
117+
@is_admin
118+
async def dkick(event, perm):
119+
if not perm.ban_users:
120+
await event.reply("You are missing the following rights to use this command:CanBanUsers!")
121+
return
122+
reply_msg = await event.get_reply_message()
123+
if not reply_msg:
124+
await event.reply("Reply to someone to delete it and kick the user!")
125+
return
126+
us = reply_msg.sender.username
127+
info = await Zaid.get_entity(us)
128+
x = await event.get_reply_message()
129+
await x.delete()
130+
await Zaid.kick_participant(event.chat_id, x.sender_id)
131+
await event.reply(f"Succesfully Kicked [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}")
132+
133+
@Zaid.on(events.NewMessage(pattern="^[!?/]dban"))
134+
@is_admin
135+
async def dban(event, perm):
136+
if not perm.ban_users:
137+
await event.reply("You are missing the following rights to use this command:CanBanUsers!")
138+
return
139+
reply_msg = await event.get_reply_message()
140+
if not reply_msg:
141+
await event.reply("Reply to someone to delete the message and ban the user!")
142+
return
143+
us = reply_msg.sender.username
144+
info = await Zaid.get_entity(us)
145+
x = (await event.get_reply_message()).sender_id
146+
zx = (await event.get_reply_message())
147+
await zx.delete()
148+
await Zaid(EditBannedRequest(event.chat_id, x, ChatBannedRights(until_date=None, view_messages=True)))
149+
await event.reply("Successfully Banned!")
150+
await event.reply(f"Succesfully Banned [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}")
151+
152+
@Zaid.on(events.NewMessage(pattern="^[!?/]sban"))
153+
@is_admin
154+
async def sban(event, perm):
155+
if not perm.ban_users:
156+
await event.reply("You are missing the following rights to use this command:CanBanUsers!")
157+
return
158+
reply_msg = await event.get_reply_message()
159+
if not reply_msg:
160+
await event.reply("Reply to someone to delete the message and ban the user!")
161+
return
162+
us = reply_msg.sender.username
163+
info = await Zaid.get_entity(us)
164+
x = (await event.get_reply_message()).sender_id
165+
zx = (await event.get_reply_message())
166+
await event.delete()
167+
await Zaid(EditBannedRequest(event.chat_id, x, ChatBannedRights(until_date=None, view_messages=True)))
168+
await event.reply(f"Succesfully Banned [{info.first_name}](tg://user?id={replied_user}) from {event.chat.title}")
169+
170+
@Zaid.on(events.callbackquery.CallbackQuery(data="bans"))
171+
async def banhelp(event):
172+
await event.edit(BANS_TEXT, buttons=[[Button.inline("« Bᴀᴄᴋ", data="help")]])

Zaid/plugins/help.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from telethon import events, Button
2+
from Zaid import Zaid, BOT_USERNAME
3+
4+
btn =[
5+
[Button.inline("Admin", data="admin"), Button.inline("Bans", data="bans")],
6+
[Button.inline("Pins", data="pins"), Button.inline("Pugres", data="purges")],
7+
[Button.inline("Play", data="play"), Button.inline("Chat Cleaner", data="zombies")],
8+
[Button.inline("Locks", data="locks"), Button.inline("Misc", data="misc")],
9+
[Button.inline("Home", data="start")]]
10+
11+
HELP_TEXT = "Welcome To help Menu Section\n\nClick on the Buttons!"
12+
13+
14+
@Zaid.on(events.NewMessage(pattern="[!?/]help"))
15+
async def help(event):
16+
17+
if event.is_group:
18+
await event.reply("Contact me in PM to get available help menu!", buttons=[
19+
[Button.url("Help And Commands!", "t.me/{}?start=help".format(BOT_USERNAME))]])
20+
return
21+
22+
await event.reply(HELP_TEXT, buttons=btn)
23+
24+
@Zaid.on(events.NewMessage(pattern="^/start help"))
25+
async def _(event):
26+
27+
await event.reply(HELP_TEXT, buttons=btn)
28+
29+
@Zaid.on(events.callbackquery.CallbackQuery(data="help"))
30+
async def _(event):
31+
32+
await event.edit(HELP_TEXT, buttons=btn)

0 commit comments

Comments
 (0)