diff --git a/main.py b/main.py index 898da57..4263ee2 100644 --- a/main.py +++ b/main.py @@ -28,7 +28,8 @@ from utils import mp, USERNAME, FFMPEG_PROCESSES from pyrogram.raw import functions, types from user import USER -from pyrogram.errors import FloodWait, UserAlreadyParticipant +from pyrogram.types import Message +from pyrogram.errors import UserAlreadyParticipant CHAT=Config.CHAT ADMINS=Config.ADMINS @@ -39,7 +40,7 @@ Config.API_ID, Config.API_HASH, bot_token=Config.BOT_TOKEN, - plugins=dict(root="plugins") + plugins=dict(root="plugins.bot") ) if not os.path.isdir("./downloads"): os.makedirs("./downloads") @@ -49,10 +50,7 @@ async def main(): try: await USER.join_chat("AsmSafone") except UserAlreadyParticipant: - return 400 - except FloodWait as e: - await asyncio.sleep(e.x) - return 404 + return except Exception as e: print(e) pass @@ -155,15 +153,15 @@ def stop_and_restart(): ) @bot.on_message(filters.command(["restart", f"restart@{USERNAME}"]) & filters.user(ADMINS) & (filters.chat(CHAT) | filters.private | filters.chat(LOG_GROUP))) -async def restart(client, message): +async def restart(_, message: Message): k=await message.reply_text("šŸ”„ **Checking Updates ...**") await asyncio.sleep(3) await k.edit("šŸ”„ **Updating, Please Wait...**") await asyncio.sleep(5) await k.edit("šŸ”„ **Successfully Updated!**") - await asyncio.sleep(2) - await k.edit("šŸ”„ **Restarting, Please Wait...\n\nJoin @AsmSafone For Updates!**") - await asyncio.sleep(10) + await asyncio.sleep(3) + await k.edit("šŸ”„ **Restarting, Please Wait...**") + await asyncio.sleep(5) process = FFMPEG_PROCESSES.get(CHAT) if process: try: @@ -178,7 +176,7 @@ async def restart(client, message): target=stop_and_restart ).start() try: - await k.delete() + await k.edit("āœ… **Restarted Successfully! \nJoin @AsmSafone For More!**") await k.reply_to_message.delete() except: pass diff --git a/plugins/helper.py b/plugins/bot/helper.py similarity index 93% rename from plugins/helper.py rename to plugins/bot/helper.py index 856cb18..4f6266b 100644 --- a/plugins/helper.py +++ b/plugins/bot/helper.py @@ -30,18 +30,20 @@ HOME_TEXT = "šŸ‘‹šŸ» **Hi [{}](tg://user?id={})**,\n\nI'm **Radio Player V3.0** \nI Can Play Radio / Music / YouTube Live In Channel & Group 24x7 Nonstop. Made with ā¤ļø By @AsmSafone šŸ˜‰!" HELP_TEXT = """ -šŸŽ§ --**Need Help ?**-- -(Join @SafoTheBot For Support) +šŸ·ļø --**Setting Up**-- : + +\u2022 Add the bot and user account in your group with admin rights. +\u2022 Start a voice chat in your group & restart the bot if not joined to vc. +\u2022 Use /play [song name] or use /play as a reply to an audio file or youtube link. šŸ·ļø --**Common Commands**-- : -\u2022 `/play` - reply to an audio or youTube link to play it or use /play [song name] -\u2022 `/help` - shows help for commands -\u2022 `/song` [song name] - download the song as audio track -\u2022 `/current` - shows playing time of current track -\u2022 `/playlist` - shows the current playlist with controls +\u2022 `/help` - shows help for all commands +\u2022 `/song` [song name] - download the song as audio +\u2022 `/current` - shows current track with controls +\u2022 `/playlist` - shows the current & queued playlist -šŸ·ļø --**Admin Commands**-- : +šŸ·ļø --**Admins Commands**-- : \u2022 `/radio` - start radio stream \u2022 `/stopradio` - stop radio stream @@ -184,7 +186,7 @@ async def cb_handler(client: Client, query: CallbackQuery): elif query.data=="help": buttons = [ [ - InlineKeyboardButton("Search Songs Inline", switch_inline_query_current_chat=""), + InlineKeyboardButton("SEARCH SONGS INLINE", switch_inline_query_current_chat=""), ], [ InlineKeyboardButton("CHANNEL", url="https://t.me/AsmSafone"), @@ -195,7 +197,7 @@ async def cb_handler(client: Client, query: CallbackQuery): InlineKeyboardButton("SOURCE CODE", url="https://github.com/AsmSafone/RadioPlayerV3"), ], [ - InlineKeyboardButton("CLOSE šŸ”", callback_data="close"), + InlineKeyboardButton("CLOSE MENU", callback_data="close"), ] ] reply_markup = InlineKeyboardMarkup(buttons) diff --git a/plugins/inline.py b/plugins/bot/inline.py similarity index 100% rename from plugins/inline.py rename to plugins/bot/inline.py diff --git a/plugins/player.py b/plugins/bot/player.py similarity index 99% rename from plugins/player.py rename to plugins/bot/player.py index cb26d61..879cffd 100644 --- a/plugins/player.py +++ b/plugins/bot/player.py @@ -18,6 +18,7 @@ import os import re +import ffmpeg import asyncio import subprocess from signal import SIGINT @@ -52,7 +53,6 @@ async def is_admin(_, client, message: Message): ADMINS_FILTER = filters.create(is_admin) - @Client.on_message(filters.command(["play", f"play@{USERNAME}"]) & (filters.chat(CHAT) | filters.private | filters.chat(LOG_GROUP)) | filters.audio & filters.private) async def yplay(_, message: Message): if ADMIN_ONLY == "True": diff --git a/plugins/radio.py b/plugins/bot/radio.py similarity index 98% rename from plugins/radio.py rename to plugins/bot/radio.py index 38f4446..5af5931 100644 --- a/plugins/radio.py +++ b/plugins/bot/radio.py @@ -38,7 +38,7 @@ async def is_admin(_, client, message: Message): @Client.on_message(filters.command(["radio", f"radio@{USERNAME}"]) & ADMINS_FILTER & (filters.chat(CHAT) | filters.private | filters.chat(LOG_GROUP))) -async def radio(client, message: Message): +async def radio(_, message: Message): if 1 in RADIO: k=await message.reply_text(f"{emoji.ROBOT} **Please Stop Existing Radio Stream!**") await mp.delete(k) diff --git a/plugins/song.py b/plugins/bot/song.py similarity index 95% rename from plugins/song.py rename to plugins/bot/song.py index 60b2f5b..3143daa 100644 --- a/plugins/song.py +++ b/plugins/bot/song.py @@ -23,6 +23,7 @@ import requests import youtube_dl from pyrogram import Client, filters +from pyrogram.types import Message from config import Config from utils import USERNAME, mp from youtube_search import YoutubeSearch @@ -41,7 +42,7 @@ def time_to_seconds(time): ## Commands -------------------------------- @Client.on_message(filters.command(["song", f"song@{USERNAME}"]) & (filters.chat(CHAT) | filters.private | filters.chat(LOG_GROUP))) -async def song(client, message): +async def song(_, message: Message): query = '' for i in message.command[1:]: query += ' ' + str(i) @@ -96,14 +97,14 @@ async def song(client, message): info_dict = ydl.extract_info(link, download=False) audio_file = ydl.prepare_filename(info_dict) ydl.process_info(info_dict) - cap = f'šŸ· Title: {title}\nā³ Duration: {duration}\nšŸ‘€ Views: {views}\nšŸŽ§ Requested By: {message.from_user.mention()} \nšŸ“¤ Uploaded By: @AsmSafone šŸ‘‘' + cap = f'šŸ· Title: {title}\nā³ Duration: {duration}\nšŸ‘€ Views: {views}\nšŸŽ§ Requested By: {message.from_user.mention()} \nšŸ“¤ Uploaded By: šŸ‡§šŸ‡© ļ¼³ļ¼‘ ļ¼¢ļ¼Æļ¼“ļ¼³' secmul, dur, dur_arr = 1, 0, duration.split(':') for i in range(len(dur_arr)-1, -1, -1): dur += (int(dur_arr[i]) * secmul) secmul *= 60 await k.edit("šŸ“¤ **Uploading Song...**") await message.reply_audio(audio_file, caption=cap, parse_mode='HTML', title=title, duration=dur, performer=performer, thumb=thumb_name) - await mp.delete(k) + await k.delete() await mp.delete(message) except Exception as e: await k.edit(f'āŒ **An Error Occured!** \n\nError:- {e}') diff --git a/plugins/safone/nopm.py b/plugins/userbot/nopm.py similarity index 100% rename from plugins/safone/nopm.py rename to plugins/userbot/nopm.py diff --git a/plugins/safone/sysinfo.py b/plugins/userbot/sysinfo.py similarity index 93% rename from plugins/safone/sysinfo.py rename to plugins/userbot/sysinfo.py index f5f335a..38289c3 100644 --- a/plugins/safone/sysinfo.py +++ b/plugins/userbot/sysinfo.py @@ -106,12 +106,12 @@ async def generate_sysinfo(workdir): @Client.on_message( - filters.group - & filters.text + filters.text + & (filters.group | filters.private) & self_or_contact_filter & ~filters.edited & ~filters.bot - & filters.regex("^!ping$") + & filters.regex("^.ping$") ) async def ping_pong(_, m: Message): start = time() @@ -123,12 +123,12 @@ async def ping_pong(_, m: Message): @Client.on_message( - filters.group - & filters.text + filters.text + & (filters.group | filters.private) & self_or_contact_filter & ~filters.edited & ~filters.bot - & filters.regex("^!uptime$") + & filters.regex("^.uptime$") ) async def get_uptime(_, m: Message): current_time = datetime.utcnow() @@ -142,14 +142,14 @@ async def get_uptime(_, m: Message): @Client.on_message( - filters.group - & filters.text + filters.text + & (filters.group | filters.private) & self_or_contact_filter & ~filters.edited & ~filters.bot - & filters.regex("^!sysinfo$") + & filters.regex("^.sysinfo$") ) -async def get_sysinfo(client, m): +async def get_sysinfo(client, m: Message): response = "**System Information**:\n" m_reply = await m.reply_text(f"{response}`...`") response += await generate_sysinfo(client.workdir) diff --git a/user.py b/user.py index 19c97fe..12b65b4 100644 --- a/user.py +++ b/user.py @@ -26,7 +26,7 @@ Config.SESSION, Config.API_ID, Config.API_HASH, - plugins=dict(root="plugins.safone") + plugins=dict(root="plugins.userbot") ) else: USER = Client(