Skip to content

Commit

Permalink
Auto Fixes: Code Formated
Browse files Browse the repository at this point in the history
Signed-off-by: AsmSafone <[email protected]>
  • Loading branch information
AsmSafone committed Aug 30, 2021
1 parent d143b4d commit 71ca405
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 37 deletions.
20 changes: 9 additions & 11 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
22 changes: 12 additions & 10 deletions plugins/helper.py → plugins/bot/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand All @@ -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)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/player.py → plugins/bot/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import os
import re
import ffmpeg
import asyncio
import subprocess
from signal import SIGINT
Expand Down Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion plugins/radio.py → plugins/bot/radio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions plugins/song.py → plugins/bot/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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'🏷 <b>Title:</b> <a href="{link}">{title}</a>\n⏳ <b>Duration:</b> <code>{duration}</code>\n👀 <b>Views:</b> <code>{views}</code>\n🎧 <b>Requested By:</b> {message.from_user.mention()} \n📤 <b>Uploaded By: @AsmSafone</b> 👑'
cap = f'🏷 <b>Title:</b> <a href="{link}">{title}</a>\n⏳ <b>Duration:</b> <code>{duration}</code>\n👀 <b>Views:</b> <code>{views}</code>\n🎧 <b>Requested By:</b> {message.from_user.mention()} \n📤 <b>Uploaded By: <a href="https://t.me/AsmSafone">🇧🇩 S1 BOTS</a></b>'
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}')
Expand Down
File renamed without changes.
20 changes: 10 additions & 10 deletions plugins/safone/sysinfo.py → plugins/userbot/sysinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 71ca405

Please sign in to comment.