-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
190 lines (181 loc) · 5.69 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
"""
This Project Under Team-Silent💞 < @SILENT_DEVS >
Orgination Github Of this TeamSilent < https://github.com/TeamSilentt > Check out
Creator Or Dev @HYPER_AD13 | @SHINING_OFF <Found On telegram>
Found on github < https://github.com/HYPER-AD17 >
©Team Silent™.
"""
import os
import sys
import asyncio
import subprocess
from time import sleep
from threading import Thread
from signal import SIGINT
from pyrogram import Client, filters, idle
from config import Config
from utils import mp, USERNAME, FFMPEG_PROCESSES
from pyrogram.raw.functions.bots import SetBotCommands
from pyrogram.raw.types import BotCommand, BotCommandScopeDefault
from user import USER
from pyrogram.types import Message
from pyrogram.errors import UserAlreadyParticipant
ADMINS=Config.ADMINS
CHAT_ID=Config.CHAT_ID
LOG_GROUP=Config.LOG_GROUP
bot = Client(
"RadioPlayer",
Config.API_ID,
Config.API_HASH,
bot_token=Config.BOT_TOKEN,
plugins=dict(root="plugins.bot")
)
if not os.path.isdir("./downloads"):
os.makedirs("./downloads")
async def main():
async with bot:
await mp.start_radio()
try:
await USER.join_chat("SILENT_DEVS")
await USER.join_chat("SILENT_BOTS")
await USER.join_chat("SilentVerse")
except UserAlreadyParticipant:
pass
except Exception as e:
print(e)
pass
def stop_and_restart():
bot.stop()
os.system("git pull")
sleep(10)
os.execl(sys.executable, sys.executable, *sys.argv)
bot.run(main())
bot.start()
print("""╭┈┈┈┈┈┈┈┈┈┈┈┈𑁍ࠬ┈┈┈╮
❝sɪʟᴇɴᴛ ʀᴀᴅɪᴏ ᴘʟᴀʏᴇʀ⚡❞
❝sᴛᴀᴛᴜs » sᴛᴀʀᴛᴇᴅ 🥀❞
❝ᴅᴇᴠ » ɪᴛ's ʜʏᴘᴇʀ🇮🇳❞
❝ᴊᴏɪɴ @SILENT_DEVS❞
╰┈┈┈𑁍ࠬ┈┈┈┈┈┈┈┈┈┈┈┈╯""")
bot.send(
SetBotCommands(
scope=BotCommandScopeDefault(),
lang_code="en",
commands=[
BotCommand(
command="start",
description="Start The Bot"
),
BotCommand(
command="help",
description="Show Help Message"
),
BotCommand(
command="splay",
description="Play Music From YouTube"
),
BotCommand(
command="song",
description="Download Music As Audio"
),
BotCommand(
command="next",
description="Skip The Current Music"
),
BotCommand(
command="pause",
description="Pause The Current Music"
),
BotCommand(
command="resume",
description="Resume The Paused Music"
),
BotCommand(
command="radio",
description="Start Radio / Live Stream"
),
BotCommand(
command="current",
description="Show Current Playing Song"
),
BotCommand(
command="playlist",
description="Show The Current Playlist"
),
BotCommand(
command="joinvc",
description="Join To The Voice Chat"
),
BotCommand(
command="leavevc",
description="Leave From The Voice Chat"
),
BotCommand(
command="end",
description="Stop Playing The Music"
),
BotCommand(
command="stopradio",
description="Stop Radio / Live Stream"
),
BotCommand(
command="rplay",
description="Replay From The Begining"
),
BotCommand(
command="rms",
description="Clean Unused RAW PCM Files"
),
BotCommand(
command="pmute",
description="Mute Userbot In Voice Chat"
),
BotCommand(
command="punmute",
description="Unmute Userbot In Voice Chat"
),
BotCommand(
command="vol",
description="Change The Voice Chat Volume"
),
BotCommand(
command="restart",
description="Update & Restart Bot (Owner Only)"
),
BotCommand(
command="setvar",
description="Set / Change Configs Var (For Heroku)"
)
]
)
)
@bot.on_message(filters.command(["restart", f"restart@{USERNAME}"]) & filters.user(ADMINS) & (filters.chat(CHAT_ID) | filters.private | filters.chat(LOG_GROUP)))
async def restart(_, message: Message):
k=await message.reply_text("🔄 **ᴡᴀɪᴛ ...**")
await asyncio.sleep(3)
if Config.HEROKU_APP:
await k.edit("🔄 **ʜᴜʜ, \nʀᴇsᴛᴀʀᴛɪɴɢ ʀᴏʙᴏᴛ...**")
Config.HEROKU_APP.restart()
else:
await k.edit("🔄 **ᴡᴀɪᴛ ғᴏʀ ᴀ ᴡʜɪʟᴇ...**")
process = FFMPEG_PROCESSES.get(CHAT_ID)
if process:
try:
process.send_signal(SIGINT)
except subprocess.TimeoutExpired:
process.kill()
except Exception as e:
print(e)
pass
FFMPEG_PROCESSES[CHAT_ID] = ""
Thread(
target=stop_and_restart()
).start()
try:
await k.edit("✅ **ʀᴇsᴛᴀʀᴛ ᴅᴏɴᴇ ʏᴜᴘ!**")
await k.reply_to_message.delete()
except:
pass
idle()
print("\n\nRadio Player Bot Stopped, ᴀᴡᴡ")
bot.stop()