diff --git a/.gitignore b/.gitignore index 0d23458a..9900706a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .env +.winx.env .cache Winxlogs.txt .DS_Store diff --git a/WinxMusic/core/bot.py b/WinxMusic/core/bot.py index e6b594fb..77b43af4 100644 --- a/WinxMusic/core/bot.py +++ b/WinxMusic/core/bot.py @@ -161,6 +161,6 @@ async def stop(self): LOGGER(__name__).info("Bot is shutting down") await self.send_message( config.LOG_GROUP_ID, - text=f"🛑{self.mention} Bot Desligado :\n\n🆔 Id: {self.id}\n📛 Nome: {self.name}\n🔗 Nome de usuário: @{self.username}", + text=f"🛑 {self.mention} Bot Desligado :\n\n🆔 Id: {self.id}\n📛 Nome: {self.name}\n🔗 Nome de usuário: @{self.username}", ) await super().stop() diff --git a/WinxMusic/core/call.py b/WinxMusic/core/call.py index d6bd770b..33b6fd4b 100644 --- a/WinxMusic/core/call.py +++ b/WinxMusic/core/call.py @@ -97,11 +97,11 @@ async def force_stop_stream(self, chat_id: int): pass async def skip_stream( - self, - chat_id: int, - link: str, - video: Union[bool, str] = None, - image: Union[bool, str] = None, + self, + chat_id: int, + link: str, + video: Union[bool, str] = None, + image: Union[bool, str] = None, ): assistant = await group_assistant(self, chat_id) audio_stream_quality = await get_audio_bitrate(chat_id) @@ -159,12 +159,12 @@ async def stream_call(self, link): await assistant.leave_call(config.LOG_GROUP_ID) async def join_call( - self, - chat_id: int, - original_chat_id: int, - link, - video: Union[bool, str] = None, - image: Union[bool, str] = None, + self, + chat_id: int, + original_chat_id: int, + link, + video: Union[bool, str] = None, + image: Union[bool, str] = None, ): assistant = await group_assistant(self, chat_id) audio_stream_quality = await get_audio_bitrate(chat_id) diff --git a/WinxMusic/platforms/Carbon.py b/WinxMusic/platforms/Carbon.py index 1769cd4c..b8080186 100644 --- a/WinxMusic/platforms/Carbon.py +++ b/WinxMusic/platforms/Carbon.py @@ -79,7 +79,7 @@ def __init__(self): async def generate(self, text: str, user_id): async with aiohttp.ClientSession( - headers={"Content-Type": "application/json"}, + headers={"Content-Type": "application/json"}, ) as ses: params = { "code": text, diff --git a/WinxMusic/platforms/Telegram.py b/WinxMusic/platforms/Telegram.py index 94ab4fb5..e3326b25 100644 --- a/WinxMusic/platforms/Telegram.py +++ b/WinxMusic/platforms/Telegram.py @@ -28,7 +28,7 @@ def __init__(self): async def send_split_text(self, message, string): n = self.chars_limit - out = [(string[i : i + n]) for i in range(0, len(string), n)] + out = [(string[i: i + n]) for i in range(0, len(string), n)] j = 0 for x in out: if j <= 2: @@ -61,20 +61,20 @@ async def get_duration(self, file: Union[Video, Voice, Message]): return dur async def get_filepath( - self, - audio: Union[Voice, Message, bool, str] = None, - video: Union[Video, Message, bool, str] = None, + self, + audio: Union[Voice, Message, bool, str] = None, + video: Union[Video, Message, bool, str] = None, ): if audio: try: file_name = ( - audio.file_unique_id - + "." - + ( - (audio.file_name.split(".")[-1]) - if (not isinstance(audio, Voice)) - else "ogg" - ) + audio.file_unique_id + + "." + + ( + (audio.file_name.split(".")[-1]) + if (not isinstance(audio, Voice)) + else "ogg" + ) ) except: file_name = audio.file_unique_id + "." + ".ogg" @@ -82,7 +82,7 @@ async def get_filepath( if video: try: file_name = ( - video.file_unique_id + "." + (video.file_name.split(".")[-1]) + video.file_unique_id + "." + (video.file_name.split(".")[-1]) ) except: file_name = video.file_unique_id + "." + "mp4" @@ -96,20 +96,20 @@ async def is_streamable_url(self, url: str) -> bool: if response.status == 200: content_type = response.headers.get("Content-Type", "") if ( - "application/vnd.apple.mpegurl" in content_type - or "application/x-mpegURL" in content_type + "application/vnd.apple.mpegurl" in content_type + or "application/x-mpegURL" in content_type ): return True if any( - keyword in content_type - for keyword in [ - "audio", - "video", - "mp4", - "mpegurl", - "m3u8", - "mpeg", - ] + keyword in content_type + for keyword in [ + "audio", + "video", + "mp4", + "mpegurl", + "m3u8", + "mpeg", + ] ): return True if url.endswith((".m3u8", ".index", ".mp4", ".mpeg", ".mpd")): diff --git a/WinxMusic/platforms/Youtube.py b/WinxMusic/platforms/Youtube.py index 817277c0..7d054328 100644 --- a/WinxMusic/platforms/Youtube.py +++ b/WinxMusic/platforms/Youtube.py @@ -25,7 +25,7 @@ def cookies(): def get_ytdl_options( - ytdl_opts: Union[str, dict, list], commandline: bool = True + ytdl_opts: Union[str, dict, list], commandline: bool = True ) -> Union[str, dict, list]: token_data = os.getenv("TOKEN_DATA") @@ -114,7 +114,7 @@ async def url(self, message_1: Message) -> Union[str, None]: return entity.url if offset in (None,): return None - return text[offset : offset + length] + return text[offset: offset + length] async def details(self, link: str, videoid: Union[bool, str] = None): if videoid: @@ -269,10 +269,10 @@ async def formats(self, link: str, videoid: Union[bool, str] = None): return formats_available, link async def slider( - self, - link: str, - query_type: int, - videoid: Union[bool, str] = None, + self, + link: str, + query_type: int, + videoid: Union[bool, str] = None, ): if videoid: link = self.base + link @@ -287,15 +287,15 @@ async def slider( return title, duration_min, thumbnail, vidid async def download( - self, - link: str, - mystic, - video: Union[bool, str] = None, - videoid: Union[bool, str] = None, - songaudio: Union[bool, str] = None, - songvideo: Union[bool, str] = None, - format_id: Union[bool, str] = None, - title: Union[bool, str] = None, + self, + link: str, + mystic, + video: Union[bool, str] = None, + videoid: Union[bool, str] = None, + songaudio: Union[bool, str] = None, + songvideo: Union[bool, str] = None, + format_id: Union[bool, str] = None, + title: Union[bool, str] = None, ) -> str: if videoid: link = self.base + link diff --git a/WinxMusic/plugins/admins/auth.py b/WinxMusic/plugins/admins/auth.py index acabccfa..4179dc7c 100644 --- a/WinxMusic/plugins/admins/auth.py +++ b/WinxMusic/plugins/admins/auth.py @@ -8,7 +8,7 @@ get_authuser_names, save_authuser, ) -from WinxMusic.utils.decorators import AdminActual, language +from WinxMusic.utils.decorators import admin_actual, language from WinxMusic.utils.formatters import int_to_alpha from config import BANNED_USERS, adminlist from strings import command, get_command @@ -19,7 +19,7 @@ @app.on_message(filters.command(AUTH_COMMAND) & filters.group & ~BANNED_USERS) -@AdminActual +@admin_actual async def auth(_client: Client, message: Message, _): if not message.reply_to_message: if len(message.command) != 2: @@ -81,7 +81,7 @@ async def auth(_client: Client, message: Message, _): @app.on_message(filters.command(UNAUTH_COMMAND) & filters.group & ~BANNED_USERS) -@AdminActual +@admin_actual async def unauthusers(_client: Client, message: Message, _): if not message.reply_to_message: if len(message.command) != 2: diff --git a/WinxMusic/plugins/admins/callback.py b/WinxMusic/plugins/admins/callback.py index ace2efc9..44939c84 100644 --- a/WinxMusic/plugins/admins/callback.py +++ b/WinxMusic/plugins/admins/callback.py @@ -8,7 +8,7 @@ from WinxMusic.core.call import Winx from WinxMusic.misc import SUDOERS, db from WinxMusic.utils import time_to_seconds -from WinxMusic.utils.channelplay import get_channeplayCB +from WinxMusic.utils.channelplay import get_channeplay_cb from WinxMusic.utils.database import ( is_active_chat, is_music_playing, @@ -20,8 +20,8 @@ mute_on, set_loop, ) -from WinxMusic.utils.decorators import ActualAdminCB -from WinxMusic.utils.decorators.language import languageCB +from WinxMusic.utils.decorators import actual_admin_cb +from WinxMusic.utils.decorators.language import language_cb from WinxMusic.utils.formatters import seconds_to_min from WinxMusic.utils.inline.play import ( livestream_markup, @@ -53,7 +53,7 @@ @app.on_callback_query(filters.regex("PanelMarkup") & ~BANNED_USERS) -@languageCB +@language_cb async def markup_panel(client, CallbackQuery: CallbackQuery, _): await CallbackQuery.answer() callback_data = CallbackQuery.data.strip() @@ -73,7 +73,7 @@ async def markup_panel(client, CallbackQuery: CallbackQuery, _): @app.on_callback_query(filters.regex("MainMarkup") & ~BANNED_USERS) -@languageCB +@language_cb async def del_back_playlist(client, CallbackQuery, _): await CallbackQuery.answer() callback_data = CallbackQuery.data.strip() @@ -96,7 +96,7 @@ async def del_back_playlist(client, CallbackQuery, _): @app.on_callback_query(filters.regex("Pages") & ~BANNED_USERS) -@languageCB +@language_cb async def del_back_playlist(client, CallbackQuery, _): await CallbackQuery.answer() callback_data = CallbackQuery.data.strip() @@ -127,7 +127,7 @@ async def del_back_playlist(client, CallbackQuery, _): @app.on_callback_query(filters.regex("ADMIN") & ~BANNED_USERS) -@languageCB +@language_cb async def del_back_playlist(client, CallbackQuery, _): callback_data = CallbackQuery.data.strip() callback_request = callback_data.split(None, 1)[1] @@ -447,7 +447,7 @@ async def del_back_playlist(client, CallbackQuery, _): @app.on_callback_query(filters.regex("MusicStream") & ~BANNED_USERS) -@languageCB +@language_cb async def play_music(client, CallbackQuery, _): callback_data = CallbackQuery.data.strip() callback_request = callback_data.split(None, 1)[1] @@ -458,7 +458,7 @@ async def play_music(client, CallbackQuery, _): except: return try: - chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery) + chat_id, channel = await get_channeplay_cb(_, cplay, CallbackQuery) except: return user_name = CallbackQuery.from_user.first_name @@ -527,7 +527,7 @@ async def anonymous_check(client, CallbackQuery): @app.on_callback_query(filters.regex("WinxPlaylists") & ~BANNED_USERS) -@languageCB +@language_cb async def play_playlists_command(client, CallbackQuery, _): callback_data = CallbackQuery.data.strip() callback_request = callback_data.split(None, 1)[1] @@ -545,7 +545,7 @@ async def play_playlists_command(client, CallbackQuery, _): except: return try: - chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery) + chat_id, channel = await get_channeplay_cb(_, cplay, CallbackQuery) except: return user_name = CallbackQuery.from_user.first_name @@ -614,7 +614,7 @@ async def play_playlists_command(client, CallbackQuery, _): @app.on_callback_query(filters.regex("slider") & ~BANNED_USERS) -@languageCB +@language_cb async def slider_queries(client, CallbackQuery, _): callback_data = CallbackQuery.data.strip() callback_request = callback_data.split(None, 1)[1] @@ -687,7 +687,7 @@ async def close_menu(_, CallbackQuery): @app.on_callback_query(filters.regex("stop_downloading") & ~BANNED_USERS) -@ActualAdminCB +@actual_admin_cb async def stop_download(client, CallbackQuery: CallbackQuery, _): message_id = CallbackQuery.message.id task = lyrical.get(message_id) diff --git a/WinxMusic/plugins/admins/loop.py b/WinxMusic/plugins/admins/loop.py index be696fb5..3abe092e 100644 --- a/WinxMusic/plugins/admins/loop.py +++ b/WinxMusic/plugins/admins/loop.py @@ -3,7 +3,7 @@ from WinxMusic import app from WinxMusic.utils.database.memorydatabase import get_loop, set_loop -from WinxMusic.utils.decorators import AdminRightsCheck +from WinxMusic.utils.decorators import admin_rights_check from config import BANNED_USERS from strings import get_command @@ -11,7 +11,7 @@ @app.on_message(filters.command(LOOP_COMMAND) & filters.group & ~BANNED_USERS) -@AdminRightsCheck +@admin_rights_check async def admins(cli, message: Message, _, chat_id): usage = _["admin_24"] if len(message.command) != 2: diff --git a/WinxMusic/plugins/admins/pause.py b/WinxMusic/plugins/admins/pause.py index c8622e9c..46c4ad45 100644 --- a/WinxMusic/plugins/admins/pause.py +++ b/WinxMusic/plugins/admins/pause.py @@ -4,7 +4,7 @@ from WinxMusic import app from WinxMusic.core.call import Winx from WinxMusic.utils.database import is_music_playing, music_off -from WinxMusic.utils.decorators import AdminRightsCheck +from WinxMusic.utils.decorators import admin_rights_check from config import BANNED_USERS from strings import get_command @@ -12,7 +12,7 @@ @app.on_message(filters.command(PAUSE_COMMAND) & filters.group & ~BANNED_USERS) -@AdminRightsCheck +@admin_rights_check async def pause_admin(cli, message: Message, _, chat_id): if not len(message.command) == 1: return await message.reply_text(_["general_2"]) diff --git a/WinxMusic/plugins/admins/resume.py b/WinxMusic/plugins/admins/resume.py index 74a15faa..10d14b29 100644 --- a/WinxMusic/plugins/admins/resume.py +++ b/WinxMusic/plugins/admins/resume.py @@ -4,7 +4,7 @@ from WinxMusic import app from WinxMusic.core.call import Winx from WinxMusic.utils.database import is_music_playing, music_on -from WinxMusic.utils.decorators import AdminRightsCheck +from WinxMusic.utils.decorators import admin_rights_check from config import BANNED_USERS from strings import get_command @@ -12,7 +12,7 @@ @app.on_message(filters.command(RESUME_COMMAND) & filters.group & ~BANNED_USERS) -@AdminRightsCheck +@admin_rights_check async def resume_com(cli, message: Message, _, chat_id): if not len(message.command) == 1: return await message.reply_text(_["general_2"]) diff --git a/WinxMusic/plugins/admins/seek.py b/WinxMusic/plugins/admins/seek.py index 4d7d9c04..fc9053aa 100644 --- a/WinxMusic/plugins/admins/seek.py +++ b/WinxMusic/plugins/admins/seek.py @@ -4,7 +4,7 @@ from WinxMusic import YouTube, app from WinxMusic.core.call import Winx from WinxMusic.misc import db -from WinxMusic.utils import AdminRightsCheck, seconds_to_min +from WinxMusic.utils import admin_rights_check, seconds_to_min from config import BANNED_USERS from strings import get_command @@ -12,7 +12,7 @@ @app.on_message(filters.command(SEEK_COMMAND) & filters.group & ~BANNED_USERS) -@AdminRightsCheck +@admin_rights_check async def seek_comm(cli, message: Message, _, chat_id): if len(message.command) == 1: return await message.reply_text(_["admin_28"]) diff --git a/WinxMusic/plugins/admins/shuffle.py b/WinxMusic/plugins/admins/shuffle.py index 5619206b..736f0d54 100644 --- a/WinxMusic/plugins/admins/shuffle.py +++ b/WinxMusic/plugins/admins/shuffle.py @@ -5,7 +5,7 @@ from WinxMusic import app from WinxMusic.misc import db -from WinxMusic.utils.decorators import AdminRightsCheck +from WinxMusic.utils.decorators import admin_rights_check from config import BANNED_USERS from strings import get_command @@ -13,7 +13,7 @@ @app.on_message(filters.command(SHUFFLE_COMMAND) & filters.group & ~BANNED_USERS) -@AdminRightsCheck +@admin_rights_check async def admins(Client, message: Message, _, chat_id): if not len(message.command) == 1: return await message.reply_text(_["general_2"]) diff --git a/WinxMusic/plugins/admins/skip.py b/WinxMusic/plugins/admins/skip.py index 9f6fb02b..910ff38a 100644 --- a/WinxMusic/plugins/admins/skip.py +++ b/WinxMusic/plugins/admins/skip.py @@ -6,7 +6,7 @@ from WinxMusic.core.call import Winx from WinxMusic.misc import db from WinxMusic.utils.database import get_loop -from WinxMusic.utils.decorators import AdminRightsCheck +from WinxMusic.utils.decorators import admin_rights_check from WinxMusic.utils.inline.play import stream_markup, telegram_markup from WinxMusic.utils.stream.autoclear import auto_clean from WinxMusic.utils.thumbnails import gen_thumb @@ -17,7 +17,7 @@ @app.on_message(filters.command(SKIP_COMMAND) & filters.group & ~BANNED_USERS) -@AdminRightsCheck +@admin_rights_check async def skip(cli, message: Message, _, chat_id): if not len(message.command) < 2: loop = await get_loop(chat_id) diff --git a/WinxMusic/plugins/admins/vcmute.py b/WinxMusic/plugins/admins/vcmute.py index 6f6886db..28c48175 100644 --- a/WinxMusic/plugins/admins/vcmute.py +++ b/WinxMusic/plugins/admins/vcmute.py @@ -4,12 +4,12 @@ from WinxMusic import app from WinxMusic.core.call import Winx from WinxMusic.utils.database import is_muted, mute_off, mute_on -from WinxMusic.utils.decorators import AdminRightsCheck +from WinxMusic.utils.decorators import admin_rights_check from config import BANNED_USERS @app.on_message(filters.command(["vcmute"]) & filters.group & ~BANNED_USERS) -@AdminRightsCheck +@admin_rights_check async def mute_admin(cli, message: Message, _, chat_id): if not len(message.command) == 1 or message.reply_to_message: return await message.reply_text(_["general_2"]) @@ -23,7 +23,7 @@ async def mute_admin(cli, message: Message, _, chat_id): @app.on_message(filters.command(["vcunmute"]) & filters.group & ~BANNED_USERS) -@AdminRightsCheck +@admin_rights_check async def unmute_admin(Client, message: Message, _, chat_id): if not len(message.command) == 1 or message.reply_to_message: return await message.reply_text(_["general_2"]) diff --git a/WinxMusic/plugins/bot/help.py b/WinxMusic/plugins/bot/help.py index 884eee10..604c6046 100644 --- a/WinxMusic/plugins/bot/help.py +++ b/WinxMusic/plugins/bot/help.py @@ -12,7 +12,7 @@ from WinxMusic import HELPABLE, app from WinxMusic.utils.database import get_lang, is_commanddelete_on -from WinxMusic.utils.decorators.language import LanguageStart +from WinxMusic.utils.decorators.language import language_start from WinxMusic.utils.inline.help import private_help_panel from config import BANNED_USERS, START_IMG_URL from strings import get_command, get_string @@ -60,7 +60,7 @@ def paginate_modules(page_n, module_dict, chat=None, close: bool = False): ] ) - pairs = [modules[i : i + NUM_COLUMNS] for i in range(0, len(modules), NUM_COLUMNS)] + pairs = [modules[i: i + NUM_COLUMNS] for i in range(0, len(modules), NUM_COLUMNS)] max_num_pages = ceil(len(pairs) / COLUMN_SIZE) if len(pairs) > 0 else 1 modulo_page = page_n % max_num_pages @@ -83,7 +83,7 @@ def paginate_modules(page_n, module_dict, chat=None, close: bool = False): ] if len(pairs) > COLUMN_SIZE: - pairs = pairs[modulo_page * COLUMN_SIZE : COLUMN_SIZE * (modulo_page + 1)] + [ + pairs = pairs[modulo_page * COLUMN_SIZE: COLUMN_SIZE * (modulo_page + 1)] + [ navigation_buttons ] else: @@ -102,7 +102,7 @@ def paginate_modules(page_n, module_dict, chat=None, close: bool = False): @app.on_message(filters.command(HELP_COMMAND) & filters.private & ~BANNED_USERS) @app.on_callback_query(filters.regex("settings_back_helper") & ~BANNED_USERS) async def helper_private( - _client: Client, update: Union[types.Message, types.CallbackQuery] + _client: Client, update: Union[types.Message, types.CallbackQuery] ): is_callback = isinstance(update, types.CallbackQuery) if is_callback: @@ -142,7 +142,7 @@ async def helper_private( @app.on_message(filters.command(HELP_COMMAND) & filters.group & ~BANNED_USERS) -@LanguageStart +@language_start async def help_com_group(client, message: Message, _): keyboard = private_help_panel(_) await message.reply_text(_["help_2"], reply_markup=InlineKeyboardMarkup(keyboard)) @@ -176,17 +176,17 @@ async def help_button(client: Client, query: CallbackQuery): prev_page_num = int(chat_match.group(3)) close = int(chat_match.group(4)) == 1 text = ( - f"Here is the help for {HELPABLE[module].__MODULE__}:\n" - + HELPABLE[module].__HELP__ + f"Aqui está a ajuda para {HELPABLE[module].__MODULE__}:\n" + + HELPABLE[module].__HELP__ ) key = InlineKeyboardMarkup( [ [ InlineKeyboardButton( - text="↪️ Back", + text="↪️ Voltar", callback_data=f"help_back({prev_page_num},{int(close)})", ), - InlineKeyboardButton(text="🔄 close", callback_data="close"), + InlineKeyboardButton(text="🔄 Fechar", callback_data="close"), ], ] ) @@ -201,17 +201,17 @@ async def help_button(client: Client, query: CallbackQuery): prev_page_num = int(mod_match.group(2)) close = int(mod_match.group(3)) == 1 text = ( - f"Aqui está a ajuda para {HELPABLE[module].__MODULE__}:\n" - + HELPABLE[module].__HELP__ + f"Aqui está a ajuda para {HELPABLE[module].__MODULE__}:\n" + + HELPABLE[module].__HELP__ ) key = InlineKeyboardMarkup( [ [ InlineKeyboardButton( - text="↪️ Back", + text="↪️ Voltar", callback_data=f"help_back({prev_page_num},{int(close)})", ), - InlineKeyboardButton(text="🔄 close", callback_data="close"), + InlineKeyboardButton(text="🔄 Fechar", callback_data="close"), ], ] ) diff --git a/WinxMusic/plugins/bot/settings.py b/WinxMusic/plugins/bot/settings.py index af8f9dc9..d87649fb 100644 --- a/WinxMusic/plugins/bot/settings.py +++ b/WinxMusic/plugins/bot/settings.py @@ -30,8 +30,8 @@ set_playmode, set_playtype, ) -from WinxMusic.utils.decorators.admins import ActualAdminCB -from WinxMusic.utils.decorators.language import language, languageCB +from WinxMusic.utils.decorators.admins import actual_admin_cb +from WinxMusic.utils.decorators.language import language, language_cb from WinxMusic.utils.inline.settings import ( audio_quality_markup, auth_users_markup, @@ -58,7 +58,7 @@ async def settings_mar(_client: Client, message: Message, _): @app.on_callback_query(filters.regex("settings_helper") & ~BANNED_USERS) -@languageCB +@language_cb async def settings_cb(_client: Client, callback_query: CallbackQuery, _): try: await callback_query.answer(_["set_cb_8"]) @@ -75,7 +75,7 @@ async def settings_cb(_client: Client, callback_query: CallbackQuery, _): @app.on_callback_query(filters.regex("settingsback_helper") & ~BANNED_USERS) -@languageCB +@language_cb async def settings_back_markup(_client: Client, callback_query: CallbackQuery, _): try: await callback_query.answer() @@ -144,7 +144,7 @@ async def gen_buttons_vid(_, aud: str): ) & ~BANNED_USERS ) -@languageCB +@language_cb async def without_Admin_rights(_client: Client, callback_query: CallbackQuery, _): command = callback_query.matches[0].group(1) if command == "SEARCHANSWER": @@ -255,7 +255,7 @@ async def without_Admin_rights(_client: Client, callback_query: CallbackQuery, _ ) & ~BANNED_USERS ) -@ActualAdminCB +@actual_admin_cb async def aud_vid_cb(_client: Client, callback_query: CallbackQuery, _): command = callback_query.matches[0].group(1) try: @@ -303,7 +303,7 @@ async def aud_vid_cb(_client: Client, callback_query: CallbackQuery, _): @app.on_callback_query( filters.regex(pattern=r"^(CLEANMODE|COMMANDELMODE)$") & ~BANNED_USERS ) -@ActualAdminCB +@actual_admin_cb async def cleanmode_mark(_client: Client, callback_query: CallbackQuery, _): command = callback_query.matches[0].group(1) try: @@ -348,7 +348,7 @@ async def cleanmode_mark(_client: Client, callback_query: CallbackQuery, _): filters.regex(pattern=r"^(|MODECHANGE|CHANNELMODECHANGE|PLAYTYPECHANGE)$") & ~BANNED_USERS ) -@ActualAdminCB +@actual_admin_cb async def playmode_ans(_client: Client, callback_query: CallbackQuery, _): command = callback_query.matches[0].group(1) if command == "CHANNELMODECHANGE": @@ -426,7 +426,7 @@ async def playmode_ans(_client: Client, callback_query: CallbackQuery, _): # Auth Users Settings @app.on_callback_query(filters.regex(pattern=r"^(AUTH|AUTHLIST)$") & ~BANNED_USERS) -@ActualAdminCB +@actual_admin_cb async def authusers_mar(client: Client, callback_query: CallbackQuery, _): command = callback_query.matches[0].group(1) if command == "AUTHLIST": diff --git a/WinxMusic/plugins/bot/start.py b/WinxMusic/plugins/bot/start.py index fb32ad07..cfe910c6 100644 --- a/WinxMusic/plugins/bot/start.py +++ b/WinxMusic/plugins/bot/start.py @@ -21,7 +21,7 @@ is_on_off, is_served_private_chat, ) -from WinxMusic.utils.decorators.language import LanguageStart +from WinxMusic.utils.decorators.language import language_start from WinxMusic.utils.formatters import get_readable_time from WinxMusic.utils.functions import MARKDOWN, WELCOMEHELP from WinxMusic.utils.inline import private_panel, start_pannel @@ -36,7 +36,7 @@ @app.on_message(filters.command(START_COMMAND) & filters.private & ~BANNED_USERS) -@LanguageStart +@language_start async def start_comm(client: Client, message: Message, _): chat_id = message.chat.id await add_served_user(message.from_user.id) @@ -231,7 +231,7 @@ def get_stats(): @app.on_message(filters.command(START_COMMAND) & filters.group & ~BANNED_USERS) -@LanguageStart +@language_start async def testbot(_client: Client, message: Message, _): uptime = int(time.time() - _boot_) chat_id = message.chat.id diff --git a/WinxMusic/plugins/play/channel.py b/WinxMusic/plugins/play/channel.py index 61680cc8..d76aa573 100644 --- a/WinxMusic/plugins/play/channel.py +++ b/WinxMusic/plugins/play/channel.py @@ -4,7 +4,7 @@ from WinxMusic import app from WinxMusic.utils.database import set_cmode -from WinxMusic.utils.decorators.admins import AdminActual +from WinxMusic.utils.decorators.admins import admin_actual from config import BANNED_USERS from strings import get_command @@ -12,7 +12,7 @@ @app.on_message(filters.command(CHANNELPLAY_COMMAND) & filters.group & ~BANNED_USERS) -@AdminActual +@admin_actual async def playmode_(_client: Client, message: Message, _): if len(message.command) < 2: return await message.reply_text( diff --git a/WinxMusic/plugins/play/live.py b/WinxMusic/plugins/play/live.py index e26fea18..eded1fa7 100644 --- a/WinxMusic/plugins/play/live.py +++ b/WinxMusic/plugins/play/live.py @@ -2,14 +2,14 @@ from pyrogram.types import CallbackQuery from WinxMusic import YouTube, app -from WinxMusic.utils.channelplay import get_channeplayCB -from WinxMusic.utils.decorators.language import languageCB +from WinxMusic.utils.channelplay import get_channeplay_cb +from WinxMusic.utils.decorators.language import language_cb from WinxMusic.utils.stream.stream import stream from config import BANNED_USERS @app.on_callback_query(filters.regex("LiveStream") & ~BANNED_USERS) -@languageCB +@language_cb async def play_live_stream(client: Client, callback_query: CallbackQuery, _): callback_data = callback_query.data.strip() callback_request = callback_data.split(None, 1)[1] @@ -20,7 +20,7 @@ async def play_live_stream(client: Client, callback_query: CallbackQuery, _): except: return try: - chat_id, channel = await get_channeplayCB(_, cplay, callback_query) + chat_id, channel = await get_channeplay_cb(_, cplay, callback_query) except: return video = True if mode == "v" else None diff --git a/WinxMusic/plugins/play/play.py b/WinxMusic/plugins/play/play.py index 88ca4b90..a26c44f8 100644 --- a/WinxMusic/plugins/play/play.py +++ b/WinxMusic/plugins/play/play.py @@ -18,7 +18,7 @@ ) from WinxMusic.utils import seconds_to_min, time_to_seconds from WinxMusic.utils.database import is_video_allowed -from WinxMusic.utils.decorators.play import PlayWrapper +from WinxMusic.utils.decorators.play import play_wrapper from WinxMusic.utils.formatters import formats from WinxMusic.utils.inline.play import ( livestream_markup, @@ -43,17 +43,17 @@ & filters.group & ~BANNED_USERS ) -@PlayWrapper +@play_wrapper async def play_commnd( - _client: Client, - message: Message, - _, - chat_id: int, - video: bool, - channel: bool, - playmode: str, - url: str, - fplay: bool, + _client: Client, + message: Message, + _, + chat_id: int, + video: bool, + channel: bool, + playmode: str, + url: str, + fplay: bool, ): mystic = await message.reply_text( _["play_2"].format(channel) if channel else _["play_1"] diff --git a/WinxMusic/plugins/play/playlist.py b/WinxMusic/plugins/play/playlist.py index 1ff6c41c..c334aaaf 100644 --- a/WinxMusic/plugins/play/playlist.py +++ b/WinxMusic/plugins/play/playlist.py @@ -15,10 +15,10 @@ get_playlist_names, save_playlist, ) -from WinxMusic.utils.decorators import language, languageCB +from WinxMusic.utils.decorators import language, language_cb from WinxMusic.utils.decorators.play import botplaylist_markup, join_chat from WinxMusic.utils.inline.playlist import get_playlist_markup, warning_markup -from WinxMusic.utils.pastebin import Winxbin +from WinxMusic.utils.pastebin import winxbin from WinxMusic.utils.stream.stream import stream from config import BANNED_USERS, SERVER_PLAYLIST_LIMIT from strings import get_command @@ -47,7 +47,7 @@ async def check_playlist(client: Client, message: Message, _): count += 1 msg += f"\n\n{count}- {title[:70]}\n" msg += _["playlist_5"].format(duration) - link = await Winxbin(msg) + link = await winxbin(msg) lines = msg.count("\n") if lines >= 17: car = os.linesep.join(msg.split(os.linesep)[:17]) @@ -139,7 +139,7 @@ async def del_plist_msg(client, message: Message, _): @app.on_callback_query(filters.regex("play_playlist") & ~BANNED_USERS) -@languageCB +@language_cb async def play_playlist(client, CallbackQuery, _): message = CallbackQuery.message userbot = await get_assistant(message.chat.id) @@ -200,7 +200,7 @@ async def play_playlist(client, CallbackQuery, _): @app.on_message(filters.command(PLAY_PLAYLIST_COMMAND) & ~BANNED_USERS & filters.group) -@languageCB +@language_cb async def play_playlist_command(client, message, _): try: try: @@ -209,8 +209,8 @@ async def play_playlist_command(client, message, _): except ChatAdminRequired: return await msg.edit_text(_["call_1"]) if ( - get.status == ChatMemberStatus.BANNED - or get.status == ChatMemberStatus.RESTRICTED + get.status == ChatMemberStatus.BANNED + or get.status == ChatMemberStatus.RESTRICTED ): try: await app.unban_chat_member(chat_id, userbot.id) @@ -343,7 +343,7 @@ async def add_playlist(client, message: Message, _): @app.on_callback_query(filters.regex("remove_playlist") & ~BANNED_USERS) -@languageCB +@language_cb async def del_plist(client, CallbackQuery, _): callback_data = CallbackQuery.data.strip() videoid = callback_data.split(None, 1)[1] @@ -363,7 +363,7 @@ async def del_plist(client, CallbackQuery, _): @app.on_callback_query(filters.regex("remove_playlist") & ~BANNED_USERS) -@languageCB +@language_cb async def del_plist(client, CallbackQuery, _): callback_data = CallbackQuery.data.strip() videoid = callback_data.split(None, 1)[1] @@ -384,7 +384,7 @@ async def del_plist(client, CallbackQuery, _): @app.on_callback_query(filters.regex("add_playlist") & ~BANNED_USERS) -@languageCB +@language_cb async def add_playlist(client, CallbackQuery, _): callback_data = CallbackQuery.data.strip() videoid = callback_data.split(None, 1)[1] @@ -429,7 +429,7 @@ async def add_playlist(client, CallbackQuery, _): @app.on_callback_query(filters.regex("del_playlist") & ~BANNED_USERS) -@languageCB +@language_cb async def del_plist(client, CallbackQuery, _): callback_data = CallbackQuery.data.strip() videoid = callback_data.split(None, 1)[1] @@ -450,7 +450,7 @@ async def del_plist(client, CallbackQuery, _): @app.on_callback_query(filters.regex("delete_whole_playlist") & ~BANNED_USERS) -@languageCB +@language_cb async def del_whole_playlist(client, CallbackQuery, _): _playlist = await get_playlist_names(CallbackQuery.from_user.id) for x in _playlist: @@ -460,7 +460,7 @@ async def del_whole_playlist(client, CallbackQuery, _): @app.on_callback_query(filters.regex("get_playlist_playmode") & ~BANNED_USERS) -@languageCB +@language_cb async def get_playlist_playmode_(client, CallbackQuery, _): try: await CallbackQuery.answer() @@ -473,7 +473,7 @@ async def get_playlist_playmode_(client, CallbackQuery, _): @app.on_callback_query(filters.regex("home_play") & ~BANNED_USERS) -@languageCB +@language_cb async def home_play_(client, CallbackQuery, _): pass @@ -488,7 +488,7 @@ async def home_play_(client, CallbackQuery, _): @app.on_callback_query(filters.regex("delete_warning") & ~BANNED_USERS) -@languageCB +@language_cb async def delete_warning_message(client, CallbackQuery, _): try: await CallbackQuery.answer() @@ -499,7 +499,7 @@ async def delete_warning_message(client, CallbackQuery, _): @app.on_callback_query(filters.regex("del_back_playlist") & ~BANNED_USERS) -@languageCB +@language_cb async def del_back_playlist(client, CallbackQuery, _): user_id = CallbackQuery.from_user.id _playlist = await get_playlist_names(user_id) diff --git a/WinxMusic/plugins/play/stream.py b/WinxMusic/plugins/play/stream.py index e3b303c7..cd6f834e 100644 --- a/WinxMusic/plugins/play/stream.py +++ b/WinxMusic/plugins/play/stream.py @@ -5,7 +5,7 @@ import config from WinxMusic import app from WinxMusic.core.call import Winx -from WinxMusic.utils.decorators.play import PlayWrapper +from WinxMusic.utils.decorators.play import play_wrapper from WinxMusic.utils.logger import play_logs from WinxMusic.utils.stream.stream import stream from config import BANNED_USERS @@ -15,17 +15,17 @@ @app.on_message(filters.command(STREAM_COMMAND) & filters.group & ~BANNED_USERS) -@PlayWrapper +@play_wrapper async def stream_command( - _client: Client, - message: Message, - _, - chat_id, - video, - channel, - playmode, - url, - fplay, + _client: Client, + message: Message, + _, + chat_id, + video, + channel, + playmode, + url, + fplay, ): if url: mystic = await message.reply_text( diff --git a/WinxMusic/plugins/play/toptracks.py b/WinxMusic/plugins/play/toptracks.py index 8c0b04e0..02b81ce6 100644 --- a/WinxMusic/plugins/play/toptracks.py +++ b/WinxMusic/plugins/play/toptracks.py @@ -12,7 +12,7 @@ get_particulars, get_userss, ) -from WinxMusic.utils.decorators import languageCB +from WinxMusic.utils.decorators import language_cb from WinxMusic.utils.decorators.play import join_chat from WinxMusic.utils.inline.playlist import ( botplaylist_markup, @@ -26,7 +26,7 @@ @app.on_callback_query(filters.regex("get_playmarkup") & ~BANNED_USERS) -@languageCB +@language_cb async def get_play_markup(_client: Client, callback_query: CallbackQuery, _): try: await callback_query.answer() @@ -39,7 +39,7 @@ async def get_play_markup(_client: Client, callback_query: CallbackQuery, _): @app.on_callback_query(filters.regex("get_top_playlists") & ~BANNED_USERS) -@languageCB +@language_cb async def get_topz_playlists(_client: Client, callback_query: CallbackQuery, _): try: await callback_query.answer() @@ -52,7 +52,7 @@ async def get_topz_playlists(_client: Client, callback_query: CallbackQuery, _): @app.on_callback_query(filters.regex("SERVERTOP") & ~BANNED_USERS) -@languageCB +@language_cb async def server_to_play(_client: Client, callback_query: CallbackQuery, _): message = callback_query.message userbot = await get_assistant(callback_query.message.chat.id) diff --git a/WinxMusic/plugins/sudo/dev.py b/WinxMusic/plugins/sudo/dev.py index 71234f96..78333e20 100644 --- a/WinxMusic/plugins/sudo/dev.py +++ b/WinxMusic/plugins/sudo/dev.py @@ -218,13 +218,6 @@ def command(cmd: str): {command("DELSUDO_COMMAND")} [Nome de usuário, ID do usuário ou responder a um usuário] - Remover dos sudoers do bot {command("SUDOUSERS_COMMAND")} - Obter uma lista de todos os sudoers -Heroku: - -{command("USAGE_COMMAND")} - Uso de Dyno -{command("GETVAR_COMMAND")} [Nome da Variável] - Obter uma variável de configuração -{command("DELVAR_COMMAND")} [Nome da Variável] - Excluir uma variável de configuração -{command("SETVAR_COMMAND")} [Nome da Variável] [Valor] - Adicionar ou atualizar uma variável. Separe a variável e seu valor com um espaço - Comandos do Bot: {command("RESTART_COMMAND")} - Reiniciar o bot (apenas SUDOERS) diff --git a/WinxMusic/plugins/sudo/heroku.py b/WinxMusic/plugins/sudo/heroku.py index 05eb2cbe..34832481 100644 --- a/WinxMusic/plugins/sudo/heroku.py +++ b/WinxMusic/plugins/sudo/heroku.py @@ -25,9 +25,9 @@ remove_active_chat, remove_active_video_chat, ) -from WinxMusic.utils.decorators import AdminActual +from WinxMusic.utils.decorators import admin_actual from WinxMusic.utils.decorators.language import language -from WinxMusic.utils.pastebin import Winxbin +from WinxMusic.utils.pastebin import winxbin from config import BANNED_USERS from strings import get_command @@ -48,7 +48,7 @@ async def is_heroku(): async def paste_neko(code: str): - return await Winxbin(code) + return await winxbin(code) @app.on_message(filters.command(GETLOG_COMMAND) & SUDOERS) @@ -59,7 +59,7 @@ async def log_(client, message, _): if HAPP is None: return await message.reply_text(_["heroku_1"]) data = HAPP.get_log() - link = await Winxbin(data) + link = await winxbin(data) return await message.reply_text(link) else: if os.path.exists(config.LOG_FILE_NAME): @@ -247,7 +247,7 @@ async def update_(client, message, _): return await response.edit("Bot is up to date") ordinal = lambda format: "%d%s" % ( format, - "tsnrhtdd"[(format // 10 % 10 != 1) * (format % 10 < 4) * format % 10 :: 4], + "tsnrhtdd"[(format // 10 % 10 != 1) * (format % 10 < 4) * format % 10:: 4], ) updates = "".join( f"➣ #{info.count()}: {info.summary} By -> {info.author}\n\t\t\t\t➥ Commited On: {ordinal(int(datetime.fromtimestamp(info.committed_date).strftime('%d')))} {datetime.fromtimestamp(info.committed_date).strftime('%b')}, {datetime.fromtimestamp(info.committed_date).strftime('%Y')}\n\n" @@ -257,7 +257,7 @@ async def update_(client, message, _): _final_updates_ = f"{_update_response_} {updates}" if len(_final_updates_) > 4096: - url = await Winxbin(updates) + url = await winxbin(updates) nrs = await response.edit( f"**A new upadte is available for the Bot!**\n\n➣ Pushing upadtes Now\n\n__**Updates:**__\n\n[Check Upadtes]({url})", disable_web_page_preview=True, @@ -311,7 +311,7 @@ async def update_(client, message, _): @app.on_message(filters.command(REBOOT_COMMAND) & filters.group & ~BANNED_USERS) -@AdminActual +@admin_actual async def reboot(client, message: Message, _): mystic = await message.reply_text( f"Please Wait... \nRebooting{app.mention} For Your Chat." diff --git a/WinxMusic/plugins/tools/active.py b/WinxMusic/plugins/tools/active.py index 929c2b73..bd85dd9d 100644 --- a/WinxMusic/plugins/tools/active.py +++ b/WinxMusic/plugins/tools/active.py @@ -85,7 +85,7 @@ async def activevi_(_, message: Message): @app.on_message(filters.command(AC_COMMAND) & SUDOERS) async def vc(client, message: Message): ac_audio = str(len(await get_active_chats())) - await message.reply_text(f"Informações dos Chats Ativos: {ac_audio}") + await message.reply_text(f"Chats Ativos: {ac_audio}") __MODULE__ = "Ativo" diff --git a/WinxMusic/plugins/tools/languages.py b/WinxMusic/plugins/tools/languages.py index bf12f236..2cae035b 100644 --- a/WinxMusic/plugins/tools/languages.py +++ b/WinxMusic/plugins/tools/languages.py @@ -4,7 +4,7 @@ from WinxMusic import app from WinxMusic.utils.database import get_lang, set_lang -from WinxMusic.utils.decorators import ActualAdminCB, language, languageCB +from WinxMusic.utils.decorators import actual_admin_cb, language, language_cb from config import BANNED_USERS from strings import get_command, get_string, languages_present @@ -49,7 +49,7 @@ async def langs_command(client, message: Message, _): @app.on_callback_query(filters.regex("LG") & ~BANNED_USERS) -@languageCB +@language_cb async def lanuagecb(client, CallbackQuery, _): try: await CallbackQuery.answer() @@ -60,7 +60,7 @@ async def lanuagecb(client, CallbackQuery, _): @app.on_callback_query(filters.regex(r"languages:(.*?)") & ~BANNED_USERS) -@ActualAdminCB +@actual_admin_cb async def language_markup(client, CallbackQuery, _): langauge = (CallbackQuery.data).split(":")[1] old = await get_lang(CallbackQuery.message.chat.id) diff --git a/WinxMusic/plugins/tools/queue.py b/WinxMusic/plugins/tools/queue.py index 1a36d7ce..a42ae819 100644 --- a/WinxMusic/plugins/tools/queue.py +++ b/WinxMusic/plugins/tools/queue.py @@ -1,26 +1,25 @@ import asyncio -from pyrogram import filters +from pyrogram import filters, Client from pyrogram.errors import FloodWait from pyrogram.types import CallbackQuery, InputMediaPhoto, Message import config from WinxMusic import app from WinxMusic.misc import db -from WinxMusic.utils import Winxbin, get_channeplayCB, seconds_to_min +from WinxMusic.utils import winxbin, get_channeplay_cb, seconds_to_min from WinxMusic.utils.database import get_cmode, is_active_chat, is_music_playing -from WinxMusic.utils.decorators.language import language, languageCB +from WinxMusic.utils.decorators.language import language, language_cb from WinxMusic.utils.inline.queue import queue_back_markup, queue_markup from config import BANNED_USERS from strings import get_command -###Commands QUEUE_COMMAND = get_command("QUEUE_COMMAND") basic = {} -def get_image(videoid): +def get_image(videoid: str): try: url = f"https://img.youtube.com/vi/{videoid}/hqdefault.jpg" return url @@ -28,7 +27,7 @@ def get_image(videoid): return config.YOUTUBE_IMG_URL -def get_duration(playing): +def get_duration(playing: list): file_path = playing[0]["file"] if "index_" in file_path or "live_" in file_path: return "Unknown" @@ -41,7 +40,7 @@ def get_duration(playing): @app.on_message(filters.command(QUEUE_COMMAND) & filters.group & ~BANNED_USERS) @language -async def ping_com(client, message: Message, _): +async def ping_com(_client: Client, message: Message, _): if message.command[0][0] == "c": chat_id = await get_cmode(message.chat.id) if chat_id is None: @@ -75,7 +74,7 @@ async def ping_com(client, message: Message, _): if videoid == "telegram": IMAGE = ( config.TELEGRAM_AUDIO_URL - if type == "Audio" + if type == "Áudio" else config.TELEGRAM_VIDEO_URL ) elif videoid == "soundcloud": @@ -85,16 +84,16 @@ async def ping_com(client, message: Message, _): else: IMAGE = get_image(videoid) send = ( - "**⌛️ Duration:** Unknown duration limit\n\nClick on below button to get whole queued list" + "**⌛️ Duração:** Duração desconhecida\n\nClique no botão abaixo para ver a lista completa na fila" if DUR == "Unknown" - else "\nClick on below button to get whole queued list." + else "\nClique no botão abaixo para ver a lista completa na fila." ) cap = f"""**{app.mention} Player** -🎥**Playing:** {title} +🎥**Tocando agora:** {title} -🔗**Stream Type:** {type} -🙍‍♂️**Played By:** {user} +🔗**Tipo de Transmissão:** {type} +🙍‍♂️**Reproduzido por:** {user} {send}""" upl = ( queue_markup(_, DUR, "c" if cplay else "g", videoid) @@ -140,38 +139,38 @@ async def ping_com(client, message: Message, _): @app.on_callback_query(filters.regex("GetTimer") & ~BANNED_USERS) -async def quite_timer(client, CallbackQuery: CallbackQuery): +async def quite_timer(_client: Client, callback_query: CallbackQuery): try: - await CallbackQuery.answer() + await callback_query.answer() except: pass @app.on_callback_query(filters.regex("GetQueued") & ~BANNED_USERS) -@languageCB -async def queued_tracks(client, CallbackQuery: CallbackQuery, _): - callback_data = CallbackQuery.data.strip() +@language_cb +async def queued_tracks(_client: Client, callback_query: CallbackQuery, _): + callback_data = callback_query.data.strip() callback_request = callback_data.split(None, 1)[1] what, videoid = callback_request.split("|") try: - chat_id, channel = await get_channeplayCB(_, what, CallbackQuery) + chat_id, channel = await get_channeplay_cb(_, what, callback_query) except: return if not await is_active_chat(chat_id): - return await CallbackQuery.answer(_["general_6"], show_alert=True) + return await callback_query.answer(_["general_6"], show_alert=True) got = db.get(chat_id) if not got: - return await CallbackQuery.answer(_["queue_2"], show_alert=True) + return await callback_query.answer(_["queue_2"], show_alert=True) if len(got) == 1: - return await CallbackQuery.answer(_["queue_5"], show_alert=True) - await CallbackQuery.answer() + return await callback_query.answer(_["queue_5"], show_alert=True) + await callback_query.answer() basic[videoid] = False buttons = queue_back_markup(_, what) med = InputMediaPhoto( media="https://telegra.ph//file/6f7d35131f69951c74ee5.jpg", caption=_["queue_1"], ) - await CallbackQuery.edit_message_media(media=med) + await callback_query.edit_message_media(media=med) j = 0 msg = "" for x in got: @@ -185,43 +184,43 @@ async def queued_tracks(client, CallbackQuery: CallbackQuery, _): if "Queued" in msg: if len(msg) < 700: await asyncio.sleep(1) - return await CallbackQuery.edit_message_text(msg, reply_markup=buttons) + return await callback_query.edit_message_text(msg, reply_markup=buttons) if "🏷" in msg: msg = msg.replace("🏷", "") - link = await Winxbin(msg) - await CallbackQuery.edit_message_text( + link = await winxbin(msg) + await callback_query.edit_message_text( _["queue_3"].format(link), reply_markup=buttons ) else: if len(msg) > 700: if "🏷" in msg: msg = msg.replace("🏷", "") - link = await Winxbin(msg) + link = await winxbin(msg) await asyncio.sleep(1) - return await CallbackQuery.edit_message_text( + return await callback_query.edit_message_text( _["queue_3"].format(link), reply_markup=buttons ) await asyncio.sleep(1) - return await CallbackQuery.edit_message_text(msg, reply_markup=buttons) + return await callback_query.edit_message_text(msg, reply_markup=buttons) @app.on_callback_query(filters.regex("queue_back_timer") & ~BANNED_USERS) -@languageCB -async def queue_back(client, CallbackQuery: CallbackQuery, _): - callback_data = CallbackQuery.data.strip() +@language_cb +async def queue_back(_client: Client, callback_query: CallbackQuery, _): + callback_data = callback_query.data.strip() cplay = callback_data.split(None, 1)[1] try: - chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery) + chat_id, channel = await get_channeplay_cb(_, cplay, callback_query) except: return if not await is_active_chat(chat_id): - return await CallbackQuery.answer(_["general_6"], show_alert=True) + return await callback_query.answer(_["general_6"], show_alert=True) got = db.get(chat_id) if not got: - return await CallbackQuery.answer(_["queue_2"], show_alert=True) - await CallbackQuery.answer(_["set_cb_8"], show_alert=True) + return await callback_query.answer(_["queue_2"], show_alert=True) + await callback_query.answer(_["set_cb_8"], show_alert=True) file = got[0]["file"] videoid = got[0]["vidid"] user = got[0]["by"] @@ -248,16 +247,16 @@ async def queue_back(client, CallbackQuery: CallbackQuery, _): else: IMAGE = get_image(videoid) send = ( - "**⌛️ Duration:** Unknown duration limit\n\nClick on below button to get whole queued list" + "**⌛️ Duração:** Duração desconhecida\n\nClique no botão abaixo para ver a lista completa na fila" if DUR == "Unknown" - else "\nClick on below button to get whole queued list." + else "\nClique no botão abaixo para ver a lista completa na fila." ) cap = f"""**{app.mention} Player** -🎥**Playing:** {title} +🎥**Tocando agora:** {title} -🔗**Stream Type:** {type} -🙍‍♂️**Played By:** {user} +🔗**Tipo de Transmissão:** {type} +🙍‍♂️**Reproduzido por:** {user} {send}""" upl = ( queue_markup(_, DUR, cplay, videoid) @@ -274,7 +273,7 @@ async def queue_back(client, CallbackQuery: CallbackQuery, _): basic[videoid] = True med = InputMediaPhoto(media=IMAGE, caption=cap) - mystic = await CallbackQuery.edit_message_media(media=med, reply_markup=upl) + mystic = await callback_query.edit_message_media(media=med, reply_markup=upl) if DUR != "Unknown": try: while db[chat_id][0]["vidid"] == videoid: diff --git a/WinxMusic/plugins/tools/reload.py b/WinxMusic/plugins/tools/reload.py index 1a904fd9..af1d0e05 100644 --- a/WinxMusic/plugins/tools/reload.py +++ b/WinxMusic/plugins/tools/reload.py @@ -1,4 +1,4 @@ -from pyrogram import filters +from pyrogram import filters, Client from pyrogram.enums import ChatMembersFilter from pyrogram.types import Message @@ -9,13 +9,12 @@ from config import BANNED_USERS, adminlist from strings import get_command -### Multi-Lang Commands RELOAD_COMMAND = get_command("RELOAD_COMMAND") @app.on_message(filters.command(RELOAD_COMMAND) & filters.group & ~BANNED_USERS) @language -async def reload_admin_cache(client, message: Message, _): +async def reload_admin_cache(_client: Client, message: Message, _): try: chat_id = message.chat.id admins = app.get_chat_members(chat_id, filter=ChatMembersFilter.ADMINISTRATORS) @@ -30,5 +29,5 @@ async def reload_admin_cache(client, message: Message, _): await message.reply_text(_["admin_20"]) except: await message.reply_text( - "Failed to reload admincache make sure bot is an admin in your chat" - ) + "⚠️ Falha ao recarregar o cache de administradores. Certifique-se de que o bot é administrador no seu chat." + ) \ No newline at end of file diff --git a/WinxMusic/plugins/tools/songs.py b/WinxMusic/plugins/tools/songs.py index 2e7d4b9c..c95bfcc2 100644 --- a/WinxMusic/plugins/tools/songs.py +++ b/WinxMusic/plugins/tools/songs.py @@ -3,18 +3,18 @@ import yt_dlp from pykeyboard import InlineKeyboard -from pyrogram import enums, filters +from pyrogram import enums, filters, Client from pyrogram.types import ( InlineKeyboardButton, InlineKeyboardMarkup, InputMediaAudio, InputMediaVideo, - Message, + Message, CallbackQuery, ) from WinxMusic import YouTube, app from WinxMusic.platforms.Youtube import get_ytdl_options -from WinxMusic.utils.decorators.language import language, languageCB +from WinxMusic.utils.decorators.language import language, language_cb from WinxMusic.utils.formatters import convert_bytes from WinxMusic.utils.inline.song import song_markup from config import BANNED_USERS, SONG_DOWNLOAD_DURATION, SONG_DOWNLOAD_DURATION_LIMIT @@ -25,7 +25,7 @@ @app.on_message(filters.command(SONG_COMMAND) & filters.group & ~BANNED_USERS) @language -async def song_commad_group(client, message: Message, _): +async def song_command_group(_client: Client, message: Message, _): upl = InlineKeyboardMarkup( [ [ @@ -45,13 +45,11 @@ async def song_commad_group(client, message: Message, _): @app.on_message(filters.command(SONG_COMMAND) & filters.private & ~BANNED_USERS) @language -async def song_commad_private(client, message: Message, _): +async def song_command_private(_client: Client, message: Message, _): await message.delete() url = await YouTube.url(message) - if url: - if not await YouTube.exists(url): return await message.reply_text(_["song_5"]) @@ -89,7 +87,6 @@ async def song_commad_private(client, message: Message, _): return await message.reply_text(_["song_2"]) mystic = await message.reply_text(_["play_1"]) - query = message.text.split(None, 1)[1] try: @@ -103,7 +100,6 @@ async def song_commad_private(client, message: Message, _): ) = await YouTube.details(query) except: - return await mystic.edit_text(_["play_3"]) if str(duration_min) == "None": @@ -126,69 +122,50 @@ async def song_commad_private(client, message: Message, _): @app.on_callback_query(filters.regex(pattern=r"song_back") & ~BANNED_USERS) -@languageCB -async def songs_back_helper(client, CallbackQuery, _): - callback_data = CallbackQuery.data.strip() - +@language_cb +async def songs_back_helper(_client: Client, callback_query: CallbackQuery, _): + callback_data = callback_query.data.strip() callback_request = callback_data.split(None, 1)[1] - stype, vidid = callback_request.split("|") buttons = song_markup(_, vidid) - return await CallbackQuery.edit_message_reply_markup( + return await callback_query.edit_message_reply_markup( reply_markup=InlineKeyboardMarkup(buttons) ) @app.on_callback_query(filters.regex(pattern=r"song_helper") & ~BANNED_USERS) -@languageCB -async def song_helper_cb(client, CallbackQuery, _): - callback_data = CallbackQuery.data.strip() - +@language_cb +async def song_helper_cb(_client: Client, callback_query: CallbackQuery, _): + callback_data = callback_query.data.strip() callback_request = callback_data.split(None, 1)[1] - stype, vidid = callback_request.split("|") try: - - await CallbackQuery.answer(_["song_6"], show_alert=True) - + await callback_query.answer(_["song_6"], show_alert=True) except: - pass if stype == "audio": - try: - formats_available, link = await YouTube.formats(vidid, True) - except: - - return await CallbackQuery.edit_message_text(_["song_7"]) + return await callback_query.edit_message_text(_["song_7"]) keyboard = InlineKeyboard() - done = [] for x in formats_available: - check = x["format"] - if "audio" in check: - if x["filesize"] is None: continue form = x["format_note"].title() - if form not in done: - done.append(form) - else: - continue sz = convert_bytes(x["filesize"]) @@ -210,19 +187,14 @@ async def song_helper_cb(client, CallbackQuery, _): InlineKeyboardButton(text=_["CLOSE_BUTTON"], callback_data=f"close"), ) - return await CallbackQuery.edit_message_reply_markup(reply_markup=keyboard) + return await callback_query.edit_message_reply_markup(reply_markup=keyboard) else: - try: - formats_available, link = await YouTube.formats(vidid, True) - except Exception as e: - print(e) - - return await CallbackQuery.edit_message_text(_["song_7"]) + return await callback_query.edit_message_text(_["song_7"]) keyboard = InlineKeyboard() @@ -241,9 +213,7 @@ async def song_helper_cb(client, CallbackQuery, _): continue sz = convert_bytes(x["filesize"]) - ap = check.split("-")[1] - to = f"{ap} = {sz}" keyboard.row( @@ -261,55 +231,39 @@ async def song_helper_cb(client, CallbackQuery, _): InlineKeyboardButton(text=_["CLOSE_BUTTON"], callback_data=f"close"), ) - return await CallbackQuery.edit_message_reply_markup(reply_markup=keyboard) + return await callback_query.edit_message_reply_markup(reply_markup=keyboard) # Downloading Songs Here @app.on_callback_query(filters.regex(pattern=r"song_download") & ~BANNED_USERS) -@languageCB -async def song_download_cb(client, CallbackQuery, _): +@language_cb +async def song_download_cb(client: Client, callback_query: CallbackQuery, _): try: - - await CallbackQuery.answer("ᴅᴏᴡɴʟᴏᴀᴅɪɴɢ...") - + await callback_query.answer("📥 Baixando...") except: - pass - callback_data = CallbackQuery.data.strip() - + callback_data = callback_query.data.strip() callback_request = callback_data.split(None, 1)[1] - stype, format_id, vidid = callback_request.split("|") - - mystic = await CallbackQuery.edit_message_text(_["song_8"]) - + mystic = await callback_query.edit_message_text(_["song_8"]) yturl = f"https://www.youtube.com/watch?v={vidid}" - with yt_dlp.YoutubeDL(get_ytdl_options({"quiet": True})) as ytdl: - x = ytdl.extract_info(yturl, download=False) title = (x["title"]).title() - title = re.sub("\\W+", " ", title) - - thumb_image_path = await CallbackQuery.message.download() - + thumb_image_path = await callback_query.message.download() duration = x["duration"] if stype == "video": - - thumb_image_path = await CallbackQuery.message.download() - - width = CallbackQuery.message.photo.width - - height = CallbackQuery.message.photo.height + thumb_image_path = await callback_query.message.download() + width = callback_query.message.photo.width + height = callback_query.message.photo.height try: - file_path = await YouTube.download( yturl, mystic, @@ -317,9 +271,7 @@ async def song_download_cb(client, CallbackQuery, _): format_id=format_id, title=title, ) - except Exception as e: - return await mystic.edit_text(_["song_9"].format(e)) med = InputMediaVideo( @@ -335,26 +287,19 @@ async def song_download_cb(client, CallbackQuery, _): await mystic.edit_text(_["song_11"]) await app.send_chat_action( - chat_id=CallbackQuery.message.chat.id, + chat_id=callback_query.message.chat.id, action=enums.ChatAction.UPLOAD_VIDEO, ) try: - - await CallbackQuery.edit_message_media(media=med) - + await callback_query.edit_message_media(media=med) except Exception as e: - print(e) - return await mystic.edit_text(_["song_10"]) - os.remove(file_path) elif stype == "audio": - try: - filename = await YouTube.download( yturl, mystic, @@ -362,9 +307,7 @@ async def song_download_cb(client, CallbackQuery, _): format_id=format_id, title=title, ) - except Exception as e: - return await mystic.edit_text(_["song_9"].format(e)) med = InputMediaAudio( @@ -378,18 +321,13 @@ async def song_download_cb(client, CallbackQuery, _): await mystic.edit_text(_["song_11"]) await app.send_chat_action( - chat_id=CallbackQuery.message.chat.id, + chat_id=callback_query.message.chat.id, action=enums.ChatAction.UPLOAD_AUDIO, ) try: - - await CallbackQuery.edit_message_media(media=med) - + await callback_query.edit_message_media(media=med) except Exception as e: - print(e) - return await mystic.edit_text(_["song_10"]) - os.remove(filename) diff --git a/WinxMusic/plugins/tools/speedtest.py b/WinxMusic/plugins/tools/speedtest.py index 40b75c1a..411d781a 100644 --- a/WinxMusic/plugins/tools/speedtest.py +++ b/WinxMusic/plugins/tools/speedtest.py @@ -14,35 +14,35 @@ def testspeed(m): try: test = speedtest.Speedtest() test.get_best_server() - m = m.edit("⇆ Running Download Speedtest ...") + m = m.edit("⇆ Testando **download** ... ⬇️") test.download() - m = m.edit("⇆ Running Upload SpeedTest...") + m = m.edit("⇆ Testando **upload** ... ⬆️") test.upload() test.results.share() result = test.results.dict() - m = m.edit("↻ Sharing SpeedTest results") + m = m.edit("↻ Compartilhando os resultados do SpeedTest ... 📊") except Exception as e: - return m.edit(e) + return m.edit(f"⚠️ Erro: {e}") return result @app.on_message(filters.command(SPEEDTEST_COMMAND) & SUDOERS) async def speedtest_function(client, message): - m = await message.reply_text("ʀᴜɴɴɪɴɢ sᴘᴇᴇᴅᴛᴇsᴛ") + m = await message.reply_text("🚀 **Iniciando SpeedTest**...") loop = asyncio.get_event_loop_policy().get_event_loop() result = await loop.run_in_executor(None, testspeed, m) - output = f"""**Speedtest Results** - -**Client:** -**ISP :** {result['client']['isp']} -**Country :** {result['client']['country']} - -**Server:** -**Name :** {result['server']['name']} -**Country:** {result['server']['country']}, {result['server']['cc']} -**Sponsor:** {result['server']['sponsor']} -**Latency:** {result['server']['latency']} -**Ping :** {result['ping']}""" + output = f"""**Resultados do SpeedTest** 📊 + +**Cliente:** +🌐 **ISP :** {result['client']['isp']} +🏳️ **País :** {result['client']['country']} + +**Servidor:** +🌍 **Nome :** {result['server']['name']} +🇦🇺 **País:** {result['server']['country']}, {result['server']['cc']} +💼 **Patrocinador:** {result['server']['sponsor']} +⚡ **Latência:** {result['server']['latency']} ms +🏓 **Ping :** {result['ping']} ms""" msg = await app.send_photo( chat_id=message.chat.id, photo=result["share"], caption=output ) diff --git a/WinxMusic/plugins/tools/stats.py b/WinxMusic/plugins/tools/stats.py index b440a8c2..33fbeb91 100644 --- a/WinxMusic/plugins/tools/stats.py +++ b/WinxMusic/plugins/tools/stats.py @@ -3,7 +3,7 @@ from sys import version as pyver import psutil -from pyrogram import __version__ as pyrover +from pyrogram import __version__ as pyrover, Client from pyrogram import filters from pyrogram.errors import MessageIdInvalid from pyrogram.types import CallbackQuery, InputMediaPhoto, Message @@ -24,7 +24,7 @@ get_top_chats, get_topp_users, ) -from WinxMusic.utils.decorators.language import language, languageCB +from WinxMusic.utils.decorators.language import language, language_cb from WinxMusic.utils.inline.stats import ( back_stats_buttons, back_stats_markup, @@ -44,23 +44,23 @@ @app.on_message(filters.command(STATS_COMMAND) & ~BANNED_USERS) @language -async def stats_global(client, message: Message, _): +async def stats_global(_client: Client, message: Message, _): upl = stats_buttons(_, True if message.from_user.id in SUDOERS else False) await message.reply_photo( photo=config.STATS_IMG_URL, - caption=_["gstats_11"].format(app.mention), + caption=_["gstats_11"].format(app.mention) + " 📊", reply_markup=upl, ) @app.on_message(filters.command(GSTATS_COMMAND) & ~BANNED_USERS) @language -async def gstats_global(client, message: Message, _): - mystic = await message.reply_text(_["gstats_1"]) +async def gstats_global(_client: Client, message: Message, _): + mystic = await message.reply_text(_["gstats_1"] + " ⏳") stats = await get_global_tops() if not stats: await asyncio.sleep(1) - return await mystic.edit(_["gstats_2"]) + return await mystic.edit(_["gstats_2"] + " 🚫") def get_stats(): results = {} @@ -75,7 +75,7 @@ def get_stats(): ) ) if not results: - return mystic.edit(_["gstats_2"]) + return mystic.edit(_["gstats_2"] + " 🚫") videoid = None co = None for vidid, count in list_arranged.items(): @@ -100,7 +100,7 @@ def get_stats(): vidid, ) = await YouTube.details(videoid, True) title = title.title() - final = f"Top played Tracks on {app.mention}\n\n**Title:** {title}\n\nPlayed** {co} **times" + final = f"🎶 **Faixas mais tocadas no {app.mention}** 🎶\n\n**Título:** {title}\n\nTocada **{co}** vezes" upl = get_stats_markup(_, True if message.from_user.id in SUDOERS else False) await app.send_photo( message.chat.id, @@ -112,20 +112,20 @@ def get_stats(): @app.on_callback_query(filters.regex("GetStatsNow") & ~BANNED_USERS) -@languageCB -async def top_users_ten(client, CallbackQuery: CallbackQuery, _): - chat_id = CallbackQuery.message.chat.id - callback_data = CallbackQuery.data.strip() +@language_cb +async def top_users_ten(_client: Client, callback_query: CallbackQuery, _): + chat_id = callback_query.message.chat.id + callback_data = callback_query.data.strip() what = callback_data.split(None, 1)[1] upl = back_stats_markup(_) try: - await CallbackQuery.answer() + await callback_query.answer() except: pass - mystic = await CallbackQuery.edit_message_text( + mystic = await callback_query.edit_message_text( _["gstats_3"].format( - f"ᴏғ {CallbackQuery.message.chat.title}" if what == "Here" else what - ) + f"do {callback_query.message.chat.title}" if what == "Here" else what + ) + " 🔝" ) if what == "Tracks": stats = await get_global_tops() @@ -137,7 +137,7 @@ async def top_users_ten(client, CallbackQuery: CallbackQuery, _): stats = await get_particulars(chat_id) if not stats: await asyncio.sleep(1) - return await mystic.edit(_["gstats_2"], reply_markup=upl) + return await mystic.edit(_["gstats_2"] + " 🚫", reply_markup=upl) queries = await get_queries() def get_stats(): @@ -153,7 +153,7 @@ def get_stats(): ) ) if not results: - return mystic.edit(_["gstats_2"], reply_markup=upl) + return mystic.edit(_["gstats_2"] + " 🚫", reply_markup=upl) msg = "" limit = 0 total_count = 0 @@ -166,9 +166,9 @@ def get_stats(): details = stats.get(items) title = (details["title"][:35]).title() if items == "telegram": - msg += f"🔗[TelegramVideos and media's](https://t.me/telegram) ** Played {count} Times**\n\n" + msg += f"🔗[TelegramVídeos e mídias](https://t.me/telegram) **Tocado {count} vezes**\n\n" else: - msg += f"🔗 [{title}](https://www.youtube.com/watch?v={items}) ** Played {count} Times**\n\n" + msg += f"🔗 [{title}](https://www.youtube.com/watch?v={items}) **Tocado {count} vezes**\n\n" temp = ( _["gstats_4"].format( @@ -206,36 +206,36 @@ def get_stats(): except: continue limit += 1 - msg += f"🔗`{extract}` Played {count} Times on bot.\n\n" + msg += f"🔗`{extract}` Tocou {count} vezes no bot.\n\n" temp = ( _["gstats_5"].format(limit, app.mention) if what == "Chats" else _["gstats_6"].format(limit, app.mention) ) msg = temp + msg - med = InputMediaPhoto(media=config.GLOBAL_IMG_URL, caption=msg) + med = InputMediaPhoto(media=config.GLOBAL_IMG_URL, caption=msg + " 🎧") try: - await CallbackQuery.edit_message_media(media=med, reply_markup=upl) + await callback_query.edit_message_media(media=med, reply_markup=upl) except MessageIdInvalid: - await CallbackQuery.message.reply_photo( - photo=config.GLOBAL_IMG_URL, caption=msg, reply_markup=upl + await callback_query.message.reply_photo( + photo=config.GLOBAL_IMG_URL, caption=msg + " 🎧", reply_markup=upl ) @app.on_callback_query(filters.regex("TopOverall") & ~BANNED_USERS) -@languageCB -async def overall_stats(client, CallbackQuery, _): - callback_data = CallbackQuery.data.strip() +@language_cb +async def overall_stats(_client: Client, callback_query: CallbackQuery, _): + callback_data = callback_query.data.strip() what = callback_data.split(None, 1)[1] if what != "s": upl = overallback_stats_markup(_) else: upl = back_stats_buttons(_) try: - await CallbackQuery.answer() + await callback_query.answer() except: pass - await CallbackQuery.edit_message_text(_["gstats_8"]) + await callback_query.edit_message_text(_["gstats_8"] + " 📈") served_chats = len(await get_served_chats()) served_users = len(await get_served_users()) total_queries = await get_queries() @@ -248,39 +248,39 @@ async def overall_stats(client, CallbackQuery, _): song = config.SONG_DOWNLOAD_DURATION play_duration = config.DURATION_LIMIT_MIN if config.AUTO_LEAVING_ASSISTANT == str(True): - ass = "Yes" + ass = "Sim" else: - ass = "No" - text = f"""**Bot's Stats and information:** + ass = "Não" + text = f"""📊 **Estatísticas e informações do Bot:** + +🧩 **Módulos importados:** {mod} +👥 **Chats atendidos:** {served_chats} +👤 **Usuários atendidos:** {served_users} +🚫 **Usuários bloqueados:** {blocked} +🔑 **Usuários Sudo:** {sudoers} -**Imported Modules:** {mod} -**Served chats:** {served_chats} -**Served Users:** {served_users} -**Blocked Users:** {blocked} -**Sudo Users:** {sudoers} - -**Total Queries:** {total_queries} -**Total Assistant:** {assistant} -**Auto Leaving Assistsant:** {ass} +🔍 **Total de Consultas:** {total_queries} +🤖 **Total de Assistentes:** {assistant} +💨 **Assistente de Saída Automática:** {ass} -**Play Duration Limit:** {play_duration} ᴍɪɴs -**Song Download Limit:** {song} ᴍɪɴs -**Bot's Server Playlist Limit:** {playlist_limit} -**Playlist Play Limit:** {fetch_playlist}""" +⏳ **Duração de Reprodução:** {play_duration} minutos +🎵 **Download de Música:** {song} minutos +📀 **Playlist no Servidor do Bot:** {playlist_limit} +🎶 **Reprodução de Playlist:** {fetch_playlist}""" med = InputMediaPhoto(media=config.STATS_IMG_URL, caption=text) try: - await CallbackQuery.edit_message_media(media=med, reply_markup=upl) + await callback_query.edit_message_media(media=med, reply_markup=upl) except MessageIdInvalid: - await CallbackQuery.message.reply_photo( + await callback_query.message.reply_photo( photo=config.STATS_IMG_URL, caption=text, reply_markup=upl ) @app.on_callback_query(filters.regex("bot_stats_sudo")) -@languageCB +@language_cb async def overall_stats(client, CallbackQuery, _): if CallbackQuery.from_user.id not in SUDOERS: - return await CallbackQuery.answer("ᴏɴʟʏ ғᴏʀ sᴜᴅᴏ ᴜsᴇʀ's", show_alert=True) + return await CallbackQuery.answer("🔐 Somente para usuários Sudo", show_alert=True) callback_data = CallbackQuery.data.strip() what = callback_data.split(None, 1)[1] if what != "s": @@ -291,11 +291,11 @@ async def overall_stats(client, CallbackQuery, _): await CallbackQuery.answer() except: pass - await CallbackQuery.edit_message_text(_["gstats_8"]) + await CallbackQuery.edit_message_text(_["gstats_8"] + " 📊") sc = platform.system() p_core = psutil.cpu_count(logical=False) t_core = psutil.cpu_count(logical=True) - ram = str(round(psutil.virtual_memory().total / (1024.0**3))) + " GB" + ram = str(round(psutil.virtual_memory().total / (1024.0 ** 3))) + " GB" try: cpu_freq = psutil.cpu_freq().current if cpu_freq >= 1000: @@ -303,13 +303,13 @@ async def overall_stats(client, CallbackQuery, _): else: cpu_freq = f"{round(cpu_freq, 2)}MHz" except: - cpu_freq = "Unable to Fetch" + cpu_freq = "Não foi possível obter" hdd = psutil.disk_usage("/") - total = hdd.total / (1024.0**3) + total = hdd.total / (1024.0 ** 3) total = str(total) - used = hdd.used / (1024.0**3) + used = hdd.used / (1024.0 ** 3) used = str(used) - free = hdd.free / (1024.0**3) + free = hdd.free / (1024.0 ** 3) free = str(free) mod = len(ALL_MODULES) db = pymongodb @@ -325,31 +325,31 @@ async def overall_stats(client, CallbackQuery, _): total_queries = await get_queries() blocked = len(BANNED_USERS) sudoers = len(await get_sudoers()) - text = f""" **Bot Stats and information:** + text = f"""📊 **Estatísticas e informações do Bot:** -**Imported modules:** {mod} -**Platform:** {sc} -**Ram:** {ram} -**Physical Cores:** {p_core} -**Total Cores:** {t_core} -**Cpu frequency:** {cpu_freq} +🧩 **Módulos importados:** {mod} +💻 **Plataforma:** {sc} +📊 **Memória RAM:** {ram} +🖥️ **Cores físicas:** {p_core} +🖥️ **Total de Cores:** {t_core} +⚙️ **Frequência do CPU:** {cpu_freq} -**Python Version:** {pyver.split()[0]} -**Pyrogram Version:** {pyrover} -**Py-tgcalls Version:** {pytgver} -**Total Storage:** {total[:4]} ɢiʙ -**Storage Used:** {used[:4]} ɢiʙ -**Storage Left:** {free[:4]} ɢiʙ +🐍 **Versão do Python:** {pyver.split()[0]} +📦 **Versão do Pyrogram:** {pyrover} +🎧 **Versão do Py-tgcalls:** {pytgver} +💾 **Armazenamento total:** {total[:4]} GiB +💽 **Armazenamento usado:** {used[:4]} GiB +📂 **Armazenamento livre:** {free[:4]} GiB -**Served chats:** {served_chats} -**Served users:** {served_users} -**Blocked users:** {blocked} -**Sudo users:** {sudoers} +👥 **Chats atendidos:** {served_chats} +👤 **Usuários atendidos:** {served_users} +🚫 **Usuários bloqueados:** {blocked} +🔑 **Usuários Sudo:** {sudoers} -**Total DB Storage:** {storage} ᴍʙ -**Total DB Collection:** {collections} -**Total DB Keys:** {objects} -**Total Bot Queries:** `{total_queries} ` +🗄️ **Armazenamento total do BD:** {storage} MB +🗃️ **Total de Coleções do BD:** {collections} +🔑 **Total de Chaves do BD:** {objects} +🔍 **Total de Consultas no Bot:** `{total_queries} ` """ med = InputMediaPhoto(media=config.STATS_IMG_URL, caption=text) try: @@ -363,7 +363,7 @@ async def overall_stats(client, CallbackQuery, _): @app.on_callback_query( filters.regex(pattern=r"^(TOPMARKUPGET|GETSTATS|GlobalStats)$") & ~BANNED_USERS ) -@languageCB +@language_cb async def back_buttons(client, CallbackQuery, _): try: await CallbackQuery.answer() @@ -374,14 +374,14 @@ async def back_buttons(client, CallbackQuery, _): upl = top_ten_stats_markup(_) med = InputMediaPhoto( media=config.GLOBAL_IMG_URL, - caption=_["gstats_9"], + caption=_["gstats_9"] + " 🔝", ) try: await CallbackQuery.edit_message_media(media=med, reply_markup=upl) except MessageIdInvalid: await CallbackQuery.message.reply_photo( photo=config.GLOBAL_IMG_URL, - caption=_["gstats_9"], + caption=_["gstats_9"] + " 🔝", reply_markup=upl, ) if command == "GlobalStats": @@ -391,14 +391,14 @@ async def back_buttons(client, CallbackQuery, _): ) med = InputMediaPhoto( media=config.GLOBAL_IMG_URL, - caption=_["gstats_10"].format(app.mention), + caption=_["gstats_10"].format(app.mention) + " 📊", ) try: await CallbackQuery.edit_message_media(media=med, reply_markup=upl) except MessageIdInvalid: await CallbackQuery.message.reply_photo( photo=config.GLOBAL_IMG_URL, - caption=_["gstats_10"].format(app.mention), + caption=_["gstats_10"].format(app.mention) + " 📊", reply_markup=upl, ) if command == "GETSTATS": @@ -408,13 +408,13 @@ async def back_buttons(client, CallbackQuery, _): ) med = InputMediaPhoto( media=config.STATS_IMG_URL, - caption=_["gstats_11"].format(app.mention), + caption=_["gstats_11"].format(app.mention) + " 📊", ) try: await CallbackQuery.edit_message_media(media=med, reply_markup=upl) except MessageIdInvalid: await CallbackQuery.message.reply_photo( photo=config.STATS_IMG_URL, - caption=_["gstats_11"].format(app.mention), + caption=_["gstats_11"].format(app.mention) + " 📊", reply_markup=upl, ) diff --git a/WinxMusic/utils/channelplay.py b/WinxMusic/utils/channelplay.py index e5e685ea..98a3004c 100644 --- a/WinxMusic/utils/channelplay.py +++ b/WinxMusic/utils/channelplay.py @@ -1,13 +1,15 @@ +from pyrogram.types import CallbackQuery + from WinxMusic import app from WinxMusic.utils.database import get_cmode -async def get_channeplayCB(_, command, CallbackQuery): +async def get_channeplay_cb(_, command: str, callback_query: CallbackQuery): if command == "c": - chat_id = await get_cmode(CallbackQuery.message.chat.id) + chat_id = await get_cmode(callback_query.message.chat.id) if chat_id is None: try: - return await CallbackQuery.answer(_["setting_12"], show_alert=True) + return await callback_query.answer(_["setting_12"], show_alert=True) except: return try: @@ -15,10 +17,10 @@ async def get_channeplayCB(_, command, CallbackQuery): channel = chat.title except: try: - return await CallbackQuery.answer(_["cplay_4"], show_alert=True) + return await callback_query.answer(_["cplay_4"], show_alert=True) except: return else: - chat_id = CallbackQuery.message.chat.id + chat_id = callback_query.message.chat.id channel = None return chat_id, channel diff --git a/WinxMusic/utils/decorators/admins.py b/WinxMusic/utils/decorators/admins.py index 22a446e9..6c74923e 100644 --- a/WinxMusic/utils/decorators/admins.py +++ b/WinxMusic/utils/decorators/admins.py @@ -1,5 +1,6 @@ +from pyrogram import Client from pyrogram.enums import ChatMemberStatus, ChatType -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, CallbackQuery from WinxMusic import app from WinxMusic.misc import SUDOERS @@ -17,8 +18,8 @@ from ..formatters import int_to_alpha -def AdminRightsCheck(mystic): - async def wrapper(client, message): +def admin_rights_check(mystic: callable): + async def wrapper(client: Client, message: Message): if not await is_maintenance(): if message.from_user.id not in SUDOERS: return @@ -37,7 +38,7 @@ async def wrapper(client, message): [ [ InlineKeyboardButton( - text="How to Fix this? ", + text="Como resolver isso?", callback_data="AnonymousAdmin", ), ] @@ -70,8 +71,8 @@ async def wrapper(client, message): return wrapper -def AdminActual(mystic): - async def wrapper(client, message): +def admin_actual(mystic: callable): + async def wrapper(client: Client, message: Message): if not await is_maintenance(): if message.from_user.id not in SUDOERS: return @@ -93,7 +94,7 @@ async def wrapper(client, message): [ [ InlineKeyboardButton( - text="How to Fix this?", + text="Como resolver isso?", callback_data="AnonymousAdmin", ), ] @@ -108,8 +109,8 @@ async def wrapper(client, message): ) if member.status != ChatMemberStatus.ADMINISTRATOR or ( - member.privileges is None - or not member.privileges.can_manage_video_chats + member.privileges is None + or not member.privileges.can_manage_video_chats ): return await message.reply(_["general_5"]) @@ -121,47 +122,47 @@ async def wrapper(client, message): return wrapper -def ActualAdminCB(mystic): - async def wrapper(client, CallbackQuery): +def actual_admin_cb(mystic: callable): + async def wrapper(client: Client, callback_query: CallbackQuery): try: - language = await get_lang(CallbackQuery.message.chat.id) + language = await get_lang(callback_query.message.chat.id) _ = get_string(language) except: _ = get_string("pt") if not await is_maintenance(): - if CallbackQuery.from_user.id not in SUDOERS: - return await CallbackQuery.answer( + if callback_query.from_user.id not in SUDOERS: + return await callback_query.answer( _["maint_4"], show_alert=True, ) - if CallbackQuery.message.chat.type == ChatType.PRIVATE: - return await mystic(client, CallbackQuery, _) + if callback_query.message.chat.type == ChatType.PRIVATE: + return await mystic(client, callback_query, _) - is_non_admin = await is_nonadmin_chat(CallbackQuery.message.chat.id) + is_non_admin = await is_nonadmin_chat(callback_query.message.chat.id) if not is_non_admin: try: a = await app.get_chat_member( - CallbackQuery.message.chat.id, - CallbackQuery.from_user.id, + callback_query.message.chat.id, + callback_query.from_user.id, ) if a is None or ( - a.privileges is None or not a.privileges.can_manage_video_chats + a.privileges is None or not a.privileges.can_manage_video_chats ): - if CallbackQuery.from_user.id not in SUDOERS: - token = await int_to_alpha(CallbackQuery.from_user.id) - _check = await get_authuser_names(CallbackQuery.from_user.id) + if callback_query.from_user.id not in SUDOERS: + token = await int_to_alpha(callback_query.from_user.id) + _check = await get_authuser_names(callback_query.from_user.id) if token not in _check: - return await CallbackQuery.answer( + return await callback_query.answer( _["general_5"], show_alert=True, ) except Exception as e: - return await CallbackQuery.answer(f"Error: {str(e)}") + return await callback_query.answer(f"Error: {str(e)}") - return await mystic(client, CallbackQuery, _) + return await mystic(client, callback_query, _) return wrapper diff --git a/WinxMusic/utils/decorators/language.py b/WinxMusic/utils/decorators/language.py index 17d35328..d3a10ac4 100644 --- a/WinxMusic/utils/decorators/language.py +++ b/WinxMusic/utils/decorators/language.py @@ -5,7 +5,7 @@ from strings import get_string -def language(mystic): +def language(mystic: callable): async def wrapper(_, message, **kwargs): try: language = await get_lang(message.chat.id) @@ -27,7 +27,7 @@ async def wrapper(_, message, **kwargs): return wrapper -def languageCB(mystic): +def language_cb(mystic: callable): async def wrapper(_, CallbackQuery, **kwargs): try: language = await get_lang(CallbackQuery.message.chat.id) @@ -48,7 +48,7 @@ async def wrapper(_, CallbackQuery, **kwargs): return wrapper -def LanguageStart(mystic): +def language_start(mystic: callable): async def wrapper(_, message, **kwargs): try: language = await get_lang(message.chat.id) diff --git a/WinxMusic/utils/decorators/play.py b/WinxMusic/utils/decorators/play.py index 95de8236..c0a3b41e 100644 --- a/WinxMusic/utils/decorators/play.py +++ b/WinxMusic/utils/decorators/play.py @@ -1,5 +1,6 @@ import asyncio +from pyrogram import Client from pyrogram.enums import ChatMemberStatus from pyrogram.errors import ( ChannelsTooMuch, @@ -9,7 +10,7 @@ UserAlreadyParticipant, UserNotParticipant, ) -from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message from WinxMusic import YouTube, app from WinxMusic.core.call import Winx @@ -36,34 +37,34 @@ links = {} -async def join_chat(message, chat_id, _, myu, attempts=1): +async def join_chat(message: Message, chat_id: int, _, myu: Message = None, attempts=1): max_attempts = len(assistants) - 1 # Set the maximum number of attempts userbot = await get_assistant(chat_id) if chat_id in links: - invitelink = links[chat_id] + invite_link = links[chat_id] else: if message.chat.username: - invitelink = message.chat.username + invite_link = message.chat.username try: - await userbot.resolve_peer(invitelink) + await userbot.resolve_peer(invite_link) except: pass else: try: - invitelink = await app.export_chat_invite_link(message.chat.id) + invite_link = await app.export_chat_invite_link(message.chat.id) except ChatAdminRequired: return await myu.edit(_["call_1"]) except Exception as e: return await myu.edit(_["call_3"].format(app.mention, type(e).__name__)) - if invitelink.startswith("https://t.me/+"): - invitelink = invitelink.replace("https://t.me/+", "https://t.me/joinchat/") - links[chat_id] = invitelink + if invite_link.startswith("https://t.me/+"): + invite_link = invite_link.replace("https://t.me/+", "https://t.me/joinchat/") + links[chat_id] = invite_link try: await asyncio.sleep(1) - await userbot.join_chat(invitelink) + await userbot.join_chat(invite_link) except InviteRequestSent: try: await app.approve_chat_join_request(chat_id, userbot.id) @@ -99,8 +100,8 @@ async def join_chat(message, chat_id, _, myu, attempts=1): pass -def PlayWrapper(command): - async def wrapper(client, message): +def play_wrapper(command: callable): + async def wrapper(client: Client, message: Message): language = await get_lang(message.chat.id) _ = get_string(language) if message.sender_chat: @@ -108,7 +109,7 @@ async def wrapper(client, message): [ [ InlineKeyboardButton( - text="How to Fix ?", + text="Como resolver isso?", callback_data="AnonymousAdmin", ), ] @@ -123,7 +124,7 @@ async def wrapper(client, message): if PRIVATE_BOT_MODE == str(True): if not await is_served_private_chat(message.chat.id): await message.reply_text( - "**PRIVATE MUSIC BOT**\n\nOnly For Authorized chats from the owner ask my owner to allow your chat first." + "**BOT DE MÚSICA PRIVADO**\n\nSomente para chats autorizados pelo dono. Peça ao meu dono para permitir o seu chat primeiro." ) return await app.leave_chat(message.chat.id) if await is_commanddelete_on(message.chat.id): @@ -169,7 +170,7 @@ async def wrapper(client, message): is_call_active = (await app.get_chat(chat_id)).is_call_active if not is_call_active: return await message.reply_text( - "**No active video chat found **\n\nPlease make sure you started the voicechat." + "**Nenhum chat de vídeo ativo encontrado**\n\nPor favor, certifique-se de que você iniciou o chat de voz." ) except Exception: pass @@ -216,8 +217,8 @@ async def wrapper(client, message): except ChatAdminRequired: return await message.reply_text(_["call_1"]) if ( - get.status == ChatMemberStatus.BANNED - or get.status == ChatMemberStatus.RESTRICTED + get.status == ChatMemberStatus.BANNED + or get.status == ChatMemberStatus.RESTRICTED ): try: await app.unban_chat_member(chat_id, userbot.id) diff --git a/WinxMusic/utils/formatters.py b/WinxMusic/utils/formatters.py index 787b9580..a282e86b 100644 --- a/WinxMusic/utils/formatters.py +++ b/WinxMusic/utils/formatters.py @@ -56,7 +56,7 @@ async def alpha_to_int(user_id_alphabet: str) -> int: def time_to_seconds(time): stringt = str(time) - return sum(int(x) * 60**i for i, x in enumerate(reversed(stringt.split(":")))) + return sum(int(x) * 60 ** i for i, x in enumerate(reversed(stringt.split(":")))) def seconds_to_min(seconds): diff --git a/WinxMusic/utils/functions.py b/WinxMusic/utils/functions.py index b3f8d458..1db3bb54 100644 --- a/WinxMusic/utils/functions.py +++ b/WinxMusic/utils/functions.py @@ -7,81 +7,79 @@ from pyrogram.types import Message MARKDOWN = """ -ʀᴇᴀᴅ ᴛʜᴇ ʙᴇʟᴏᴡ ᴛᴇxᴛ ᴄᴀʀᴇғᴜʟʟʏ ᴛᴏ ғɪɴᴅ ᴏᴜᴛ ʜᴏᴡ ғᴏʀᴍᴀᴛᴛɪɴɢ ᴡᴏʀᴋs! +Leia o texto abaixo com atenção para descobrir como funciona a formatação! -sᴜᴘᴘᴏʀᴛᴇᴅ ғɪʟʟɪɴɢs: +Preenchimentos suportados: -{GROUPNAME} - ɢʀᴏᴜᴘ's ɴᴀᴍᴇ -{NAME} - ᴜsᴇʀ ɴᴀᴍᴇ -{ID} - ᴜsᴇʀ ɪᴅ -{FIRSTNAME} - ᴜsᴇʀ ғɪʀsᴛ ɴᴀᴍᴇ -{SURNAME} - ɪғ ᴜsᴇʀ ʜᴀs sᴜʀɴᴀᴍᴇ sᴏ ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ sᴜʀɴᴀᴍᴇ ᴇʟsᴇ ɴᴏᴛʜɪɴɢ -{USERNAME} - ᴜsᴇʀ ᴜsᴇʀɴᴀᴍᴇ +{GROUPNAME} - Nome do grupo +{NAME} - Nome do usuário +{ID} - ID do usuário +{FIRSTNAME} - Primeiro nome do usuário +{SURNAME} - Se o usuário tem sobrenome, isso mostrará o sobrenome, caso contrário, nada +{USERNAME} - Nome de usuário do usuário -{TIME} - ᴛᴏᴅᴀʏ ᴛɪᴍᴇ -{DATE} - ᴛᴏᴅᴀʏ ᴅᴀᴛᴇ -{WEEKDAY} - ᴛᴏᴅᴀʏ ᴡᴇᴇᴋᴅᴀʏ +{TIME} - Hora atual +{DATE} - Data atual +{WEEKDAY} - Dia da semana atual -NOTE: ғɪʟʟɪɴɢs ᴏɴʟʏ ᴡᴏʀᴋs ɪɴ ᴡᴇʟᴄᴏᴍᴇ ᴍᴏᴅᴜʟᴇ. +NOTA: Os preenchimentos só funcionam no módulo de boas-vindas. -sᴜᴘᴘᴏʀᴛᴇᴅ ғᴏʀᴍᴀᴛᴛɪɴɢ: +Formatação suportada: -**Bold** : ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ ᴀs Bold ᴛᴇxᴛ. -~~strike~~: ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ ᴀs strike ᴛᴇxᴛ. -__italic__: ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ ᴀs italic ᴛᴇxᴛ ---underline--: ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ ᴀs underline ᴛᴇxᴛ. -`code words`: ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ ᴀs code ᴛᴇxᴛ. -||spoiler||: ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ ᴀs Spoiler ᴛᴇxᴛ. -[hyperlink](google.com): ᴛʜɪs ᴡɪʟʟ ᴄʀᴇᴀᴛᴇ ᴀ hyperlink text -> hello ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ ᴀs
hello
-Note: ʏᴏᴜ ᴄᴀɴ ᴜsᴇ ʙᴏᴛʜ ᴍᴀʀᴋᴅᴏᴡɴ & ʜᴛᴍʟ ᴛᴀɢs. +**Negrito**: Isso aparecerá como texto em Negrito. +~~riscado~~: Isso aparecerá como texto riscado. +__itálico__: Isso aparecerá como texto em itálico. +--sublinhado--: Isso aparecerá como texto sublinhado. +`palavras de código`: Isso aparecerá como texto código. +||spoiler||: Isso aparecerá como texto Spoiler. +[hiperlink](google.com): Isso criará um hiperlink. +> olá: Isso aparecerá como
olá
. +Nota: Você pode usar tanto Markdown quanto tags HTML. -ʙᴜᴛᴛᴏɴ ғᴏʀᴍᴀᴛᴛɪɴɢ: +Formatação de botão: -- >
text ~ [button text, button link]
+- >
texto ~ [texto do botão, link do botão]
-ᴇxᴀᴍᴘʟᴇ: +Exemplo: -example -
button with markdown formatting ~ [button text, https://google.com]
+Exemplo +
botão com markdown formatação ~ [texto do botão, https://google.com]
""" WELCOMEHELP = """ -/setwelcome - ʀᴇᴘʟʏ ᴛʜɪs ᴛᴏ ᴀ ᴍᴇssᴀɢᴇ ᴄᴏɴᴛᴀɪɴɪɴɢ ᴄᴏʀʀᴇᴄᴛ -ғᴏʀᴍᴀᴛ ғᴏʀ ᴀ ᴡᴇʟᴄᴏᴍᴇ ᴍᴇssᴀɢᴇ, ᴄʜᴇᴄᴋ ᴇɴᴅ ᴏғ ᴛʜɪs ᴍᴇssᴀɢᴇ. +/setwelcome - Responda esta mensagem contendo o formato correto para uma mensagem de boas-vindas, verifique o final desta mensagem. -/delwelcome - ᴅᴇʟᴇᴛᴇ ᴛʜᴇ ᴡᴇʟᴄᴏᴍᴇ ᴍᴇssᴀɢᴇ. -/getwelcome - ɢᴇᴛ ᴛʜᴇ ᴡᴇʟᴄᴏᴍᴇ ᴍᴇssᴀɢᴇ. +/delwelcome - Apaga a mensagem de boas-vindas. +/getwelcome - Exibe a mensagem de boas-vindas. -SET_WELCOME -> +CONFIGURAR_BOAS_VINDAS -> -ᴛᴏ sᴇᴛ ᴀ ᴘʜᴏᴛᴏ ᴏʀ ɢɪғ ᴀs ᴡᴇʟᴄᴏᴍᴇ ᴍᴇssᴀɢᴇ. ᴀᴅᴅ ʏᴏᴜʀ ᴡᴇʟᴄᴏᴍᴇ ᴍᴇssᴀɢᴇ ᴀs ᴄᴀᴘᴛɪᴏɴ ᴛᴏ ᴛʜᴇ ᴘʜᴏᴛᴏ ᴏʀ ɢɪғ. ᴛʜᴇ ᴄᴀᴘᴛɪᴏɴ ᴍᴜsᴇ ʙᴇ ɪɴ ᴛʜᴇ ғᴏʀᴍᴀᴛ ɢɪᴠᴇɴ ʙᴇʟᴏᴡ. +Para definir uma foto ou GIF como mensagem de boas-vindas, adicione sua mensagem de boas-vindas como legenda da foto ou GIF. A legenda deve estar no formato abaixo. -ғᴏʀ ᴛᴇxᴛ ᴡᴇʟᴄᴏᴍᴇ ᴍᴇssᴀɢᴇ ᴊᴜsᴛ sᴇɴᴅ ᴛʜᴇ ᴛᴇxᴛ. ᴛʜᴇɴ ʀᴇᴘʟʏ ᴡɪᴛʜ ᴛʜᴇ ᴄᴏᴍᴍᴀɴᴅ +Para mensagem de boas-vindas em texto, basta enviar o texto. Em seguida, responda com o comando. -ᴛʜᴇ ғᴏʀᴍᴀᴛ sʜᴏᴜʟᴅ ʙᴇ sᴏᴍᴇᴛʜɪɴɢ ʟɪᴋᴇ ʙᴇʟᴏᴡ. +O formato deve ser algo como o seguinte: -{GROUPNAME} - ɢʀᴏᴜᴘ's ɴᴀᴍᴇ -{NAME} - ᴜsᴇʀ ғɪʀsᴛ ɴᴀᴍᴇ + sᴜʀɴᴀᴍᴇ -{ID} - ᴜsᴇʀ ɪᴅ -{FIRSTNAME} - ᴜsᴇʀ ғɪʀsᴛ ɴᴀᴍᴇ -{SURNAME} - ɪғ ᴜsᴇʀ ʜᴀs sᴜʀɴᴀᴍᴇ sᴏ ᴛʜɪs ᴡɪʟʟ sʜᴏᴡ sᴜʀɴᴀᴍᴇ ᴇʟsᴇ ɴᴏᴛʜɪɴɢ -{USERNAME} - ᴜsᴇʀ ᴜsᴇʀɴᴀᴍᴇ +{GROUPNAME} - Nome do grupo +{NAME} - Primeiro nome + sobrenome do usuário +{ID} - ID do usuário +{FIRSTNAME} - Primeiro nome do usuário +{SURNAME} - Se o usuário tem sobrenome, isso mostrará o sobrenome, caso contrário, nada +{USERNAME} - Nome de usuário do usuário -{TIME} - ᴛᴏᴅᴀʏ ᴛɪᴍᴇ -{DATE} - ᴛᴏᴅᴀʏ ᴅᴀᴛᴇ -{WEEKDAY} - ᴛᴏᴅᴀʏ ᴡᴇᴇᴋᴅᴀʏ +{TIME} - Hora atual +{DATE} - Data atual +{WEEKDAY} - Dia da semana atual - -~ #This separater (~) should be there between text and buttons, remove this comment also +~ #Esse separador (~) deve estar entre o texto e os botões, remova também este comentário. button=[Duck, https://duckduckgo.com] button2=[Github, https://github.com] -NOTES -> +NOTAS -> -ᴄʜᴇᴄᴋᴏᴜᴛ /markdownhelp ᴛᴏ ᴋɴᴏᴡ ᴍᴏʀᴇ ᴀʙᴏᴜᴛ ғᴏʀᴍᴀᴛᴛɪɴɢs ᴀɴᴅ ᴏᴛʜᴇʀ sʏɴᴛᴀx. +Verifique /markdownhelp para saber mais sobre formatações e outras sintaxes. """ @@ -150,7 +148,7 @@ async def get_data_and_name(replied_message, message): if replied_message and (replied_message.sticker or replied_message.video_note): data = None elif ( - replied_message and not replied_message.text and not replied_message.caption + replied_message and not replied_message.text and not replied_message.caption ): data = None else: @@ -171,10 +169,6 @@ async def get_data_and_name(replied_message, message): async def extract_userid(message, text: str): - """ - NOT TO BE USED OUTSIDE THIS FILE - """ - def is_int(text: str): try: int(text) @@ -208,12 +202,12 @@ async def extract_user_and_reason(message, sender_chat=False): try: if message.reply_to_message: reply = message.reply_to_message - # if reply to a message and no reason is given + # se responder a uma mensagem e nenhuma razão for dada if not reply.from_user: if ( - reply.sender_chat - and reply.sender_chat != message.chat.id - and sender_chat + reply.sender_chat + and reply.sender_chat != message.chat.id + and sender_chat ): id_ = reply.sender_chat.id else: @@ -248,9 +242,9 @@ async def extract_user(message): def get_file_id_from_message( - message, - max_file_size=3145728, - mime_types=["image/png", "image/jpeg"], + message, + max_file_size=3145728, + mime_types=["image/png", "image/jpeg"], ): file_id = None if message.document: @@ -286,13 +280,13 @@ def get_file_id_from_message( return file_id -async def time_converter(message: Message, time_value: str) -> datetime: +async def time_converter(message: Message, time_value: str) -> Message | datetime: unit = ["m", "h", "d"] check_unit = "".join(list(filter(time_value[-1].lower().endswith, unit))) currunt_time = datetime.now() time_digit = time_value[:-1] if not time_digit.isdigit(): - return await message.reply_text("Incorrect time specified") + return await message.reply_text("Tempo especificado incorreto.") if check_unit == "m": temp_time = currunt_time + timedelta(minutes=int(time_digit)) elif check_unit == "h": @@ -300,5 +294,5 @@ async def time_converter(message: Message, time_value: str) -> datetime: elif check_unit == "d": temp_time = currunt_time + timedelta(days=int(time_digit)) else: - return await message.reply_text("Incorrect time specified.") + return await message.reply_text("Tempo especificado incorreto.") return temp_time diff --git a/WinxMusic/utils/inline/play.py b/WinxMusic/utils/inline/play.py index 4732106b..c6ce01b7 100644 --- a/WinxMusic/utils/inline/play.py +++ b/WinxMusic/utils/inline/play.py @@ -5,7 +5,7 @@ from WinxMusic.utils.formatters import time_to_seconds -def get_progress_bar(percentage): +def get_progress_bar(percentage: float): umm = math.floor(percentage) if 0 < umm <= 10: @@ -32,7 +32,7 @@ def get_progress_bar(percentage): return "▱▱▱▱▱▱▱▱▱" -def stream_markup_timer(_, videoid, chat_id, played, dur): +def stream_markup_timer(_, videoid: str, chat_id: int, played: str, dur: str): played_sec = time_to_seconds(played) duration_sec = time_to_seconds(dur) percentage = (played_sec / duration_sec) * 100 diff --git a/WinxMusic/utils/inline/queue.py b/WinxMusic/utils/inline/queue.py index ad71421d..bbdcd856 100644 --- a/WinxMusic/utils/inline/queue.py +++ b/WinxMusic/utils/inline/queue.py @@ -4,12 +4,12 @@ def queue_markup( - _, - DURATION, - CPLAY, - videoid, - played: Union[bool, int] = None, - dur: Union[bool, int] = None, + _, + DURATION, + CPLAY, + videoid, + played: Union[bool, int] = None, + dur: Union[bool, int] = None, ): not_dur = [ [ diff --git a/WinxMusic/utils/inline/settings.py b/WinxMusic/utils/inline/settings.py index 28b5761c..bf9a0813 100644 --- a/WinxMusic/utils/inline/settings.py +++ b/WinxMusic/utils/inline/settings.py @@ -25,11 +25,11 @@ def setting_markup(_): def audio_quality_markup( - _, - LOW: Union[bool, str] = None, - MEDIUM: Union[bool, str] = None, - HIGH: Union[bool, str] = None, - STUDIO: Union[bool, str] = None, + _, + LOW: Union[bool, str] = None, + MEDIUM: Union[bool, str] = None, + HIGH: Union[bool, str] = None, + STUDIO: Union[bool, str] = None, ): buttons = [ [ @@ -78,13 +78,13 @@ def audio_quality_markup( def video_quality_markup( - _, - SD_360p: Union[bool, str] = None, - SD_480p: Union[bool, str] = None, - HD_720p: Union[bool, str] = None, - FHD_1080p: Union[bool, str] = None, - QHD_2K: Union[bool, str] = None, - UHD_4K: Union[bool, str] = None, + _, + SD_360p: Union[bool, str] = None, + SD_480p: Union[bool, str] = None, + HD_720p: Union[bool, str] = None, + FHD_1080p: Union[bool, str] = None, + QHD_2K: Union[bool, str] = None, + UHD_4K: Union[bool, str] = None, ): buttons = [ [ @@ -153,9 +153,9 @@ def video_quality_markup( def cleanmode_settings_markup( - _, - status: Union[bool, str] = None, - dels: Union[bool, str] = None, + _, + status: Union[bool, str] = None, + dels: Union[bool, str] = None, ): buttons = [ [ @@ -207,10 +207,10 @@ def auth_users_markup(_, status: Union[bool, str] = None): def playmode_users_markup( - _, - Direct: Union[bool, str] = None, - Group: Union[bool, str] = None, - Playtype: Union[bool, str] = None, + _, + Direct: Union[bool, str] = None, + Group: Union[bool, str] = None, + Playtype: Union[bool, str] = None, ): buttons = [ [ diff --git a/WinxMusic/utils/inlinequery.py b/WinxMusic/utils/inlinequery.py index ea0befaf..28da924e 100644 --- a/WinxMusic/utils/inlinequery.py +++ b/WinxMusic/utils/inlinequery.py @@ -5,56 +5,56 @@ answer.extend( [ InlineQueryResultArticle( - title="ᴘᴀᴜsᴇ sᴛʀᴇᴀᴍ", - description=f"ᴘᴀᴜsᴇ ᴛʜᴇ ᴄᴜʀʀᴇɴᴛ ᴘʟᴀʏɪɴɢ sᴏɴɢ ᴏɴ ᴠᴏɪᴄᴇᴄʜᴀᴛ.", + title="Pausar Transmissão", + description="Pausa a música que está sendo reproduzida no chat de voz.", thumb_url="https://telegra.ph/file/c0a1c789def7b93f13745.png", input_message_content=InputTextMessageContent("/pause"), ), InlineQueryResultArticle( - title="ʀᴇsᴜᴍᴇ sᴛʀᴇᴀᴍ", - description=f"ʀᴇsᴜᴍᴇ ᴛʜᴇ ᴘᴀᴜsᴇᴅ sᴏɴɢ ᴏɴ ᴠᴏɪᴄᴇᴄʜᴀᴛ.", + title="Retomar Transmissão", + description="Retoma a música pausada no chat de voz.", thumb_url="https://telegra.ph/file/02d1b7f967ca11404455a.png", input_message_content=InputTextMessageContent("/resume"), ), InlineQueryResultArticle( - title="ᴍᴜᴛᴇ sᴛʀᴇᴀᴍ", - description=f"ᴍᴜᴛᴇ ᴛʜᴇ ᴏɴɢᴏɪɴɢ sᴏɴɢ ᴏɴ ᴠᴏɪᴄᴇᴄʜᴀᴛ", + title="Mutar Transmissão", + description="Muta a música que está sendo reproduzida no chat de voz.", thumb_url="https://telegra.ph/file/66516f2976cb6d87e20f9.png", input_message_content=InputTextMessageContent("/vcmute"), ), InlineQueryResultArticle( - title="ᴜɴᴍᴜᴛᴇ sᴛʀᴇᴀᴍ", - description=f"ᴜɴᴍᴜᴛᴇ ᴛʜᴇ ᴏɴɢᴏɪɴɢ sᴏɴɢ ᴏɴ ᴠᴏɪᴄᴇᴄʜᴀᴛ", + title="Desmutar Transmissão", + description="Desmuta a música que está sendo reproduzida no chat de voz.", thumb_url="https://telegra.ph/file/3078794f9341ffd582e18.png", input_message_content=InputTextMessageContent("/vcunmute"), ), InlineQueryResultArticle( - title="sᴋɪᴘ sᴛʀᴇᴀᴍ", - description=f"sᴋɪᴘ ᴛᴏ ɴᴇxᴛ ᴛʀᴀᴄᴋ. | sᴋɪᴘ ᴛᴏ ɴᴇxᴛ ᴛʀᴀᴄᴋ. | ғᴏʀ sᴘᴇᴄɪғɪᴄ ᴛʀᴀᴄᴋ ɴᴜᴍʙᴇʀ: /skip [number] ", + title="Pular Transmissão", + description="Pula para a próxima faixa. Para pular para uma faixa específica: /skip [número]", thumb_url="https://telegra.ph/file/98b88e52bc625903c7a2f.png", input_message_content=InputTextMessageContent("/skip"), ), InlineQueryResultArticle( - title="ᴇɴᴅ sᴛʀᴇᴀᴍ", - description="sᴛᴏᴘ ᴛʜᴇ ᴏɴɢᴏɪɴɢ sᴏɴɢ ᴏɴ ɢʀᴏᴜᴘ ᴠᴏɪᴄᴇᴄʜᴀᴛ.", + title="Encerrar Transmissão", + description="Para a música que está sendo reproduzida no chat de voz do grupo.", thumb_url="https://telegra.ph/file/d2eb03211baaba8838cc4.png", input_message_content=InputTextMessageContent("/stop"), ), InlineQueryResultArticle( - title="sʜᴜғғʟᴇ sᴛʀᴇᴀᴍ", - description="sʜᴜғғʟᴇ ᴛʜᴇ ǫᴜᴇᴜᴇᴅ ᴛʀᴀᴄᴋs ʟɪsᴛ.", + title="Embaralhar Transmissão", + description="Embaralha a lista de músicas na fila.", thumb_url="https://telegra.ph/file/7f6aac5c6e27d41a4a269.png", input_message_content=InputTextMessageContent("/shuffle"), ), InlineQueryResultArticle( - title="sᴇᴇᴋ sᴛʀᴇᴀᴍ", - description="sᴇᴇᴋ ᴛʜᴇ ᴏɴɢᴏɪɴɢ sᴛʀᴇᴀᴍ ᴛᴏ ᴀ sᴘᴇᴄɪғɪᴄ ᴅᴜʀᴀᴛɪᴏɴ.", + title="Avançar Transmissão", + description="Avança a música para uma duração específica.", thumb_url="https://telegra.ph/file/cd25ec6f046aa8003cfee.png", input_message_content=InputTextMessageContent("/seek 10"), ), InlineQueryResultArticle( - title="ʟᴏᴏᴘ sᴛʀᴇᴀᴍ", - description="ʟᴏᴏᴘ ᴛʜᴇ ᴄᴜʀʀᴇɴᴛ ᴘʟᴀʏɪɴɢ ᴍᴜsɪᴄ. ᴜsᴀsɢᴇ: /loop [enable|disable]", + title="Repetir Transmissão", + description="Repete a música atual. Uso: /loop [ativar|desativar]", thumb_url="https://telegra.ph/file/081c20ce2074ea3e9b952.png", input_message_content=InputTextMessageContent("/loop 3"), ), diff --git a/WinxMusic/utils/keyboard.py b/WinxMusic/utils/keyboard.py index 9d99ec69..2af8eea3 100644 --- a/WinxMusic/utils/keyboard.py +++ b/WinxMusic/utils/keyboard.py @@ -4,7 +4,7 @@ from .functions import get_urls_from_text as is_url -def keyboard(buttons_list, row_width: int = 2): +def keyboard(buttons_list: list, row_width: int = 2): buttons = InlineKeyboard(row_width=row_width) data = [ ( diff --git a/WinxMusic/utils/logger.py b/WinxMusic/utils/logger.py index 27b4881b..df3affa7 100644 --- a/WinxMusic/utils/logger.py +++ b/WinxMusic/utils/logger.py @@ -1,28 +1,31 @@ +from pyrogram.types import Message + from WinxMusic import app from WinxMusic.utils.database import is_on_off from config import LOG, LOG_GROUP_ID -async def play_logs(message, streamtype): +async def play_logs(message: Message, streamtype: str): if await is_on_off(LOG): if message.chat.username: chatusername = f"@{message.chat.username}" else: - chatusername = "ᴘʀɪᴠᴀᴛᴇ ɢʀᴏᴜᴘ" + chatusername = "🔒 Grupo Privado" logger_text = f""" -**{app.mention} ᴘʟᴀʏ ʟᴏɢ** +🎵 **Registro de Reprodução - {app.mention}** 🎵 + +📌 **ID do Chat:** `{message.chat.id}` +🏷️ **Nome do Chat:** {message.chat.title} +🔗 **Nome de Usuário do Chat:** {chatusername} -**ᴄʜᴀᴛ ɪᴅ :** `{message.chat.id}` -**ᴄʜᴀᴛ ɴᴀᴍᴇ :** {message.chat.title} -**ᴄʜᴀᴛ ᴜsᴇʀɴᴀᴍᴇ :** {chatusername} +👤 **ID do Usuário:** `{message.from_user.id}` +📛 **Nome:** {message.from_user.mention} +📱 **Nome de Usuário:** @{message.from_user.username} -**ᴜsᴇʀ ɪᴅ :** `{message.from_user.id}` -**ɴᴀᴍᴇ :** {message.from_user.mention} -**ᴜsᴇʀɴᴀᴍᴇ :** @{message.from_user.username} +🔍 **Consulta:** {message.text.split(None, 1)[1]} +🎧 **Tipo de Transmissão:** {streamtype}""" -**ǫᴜᴇʀʏ :** {message.text.split(None, 1)[1]} -**sᴛʀᴇᴀᴍᴛʏᴘᴇ :** {streamtype}""" if message.chat.id != LOG_GROUP_ID: try: await app.send_message( diff --git a/WinxMusic/utils/pastebin.py b/WinxMusic/utils/pastebin.py index 2d93c366..04fab052 100644 --- a/WinxMusic/utils/pastebin.py +++ b/WinxMusic/utils/pastebin.py @@ -3,7 +3,7 @@ BASE = "https://batbin.me/" -async def post(url: str, *args, **kwargs): +async def post(url: str, *args: list, **kwargs: dict): async with aiohttp.ClientSession() as session: async with session.post(url, *args, **kwargs) as resp: try: @@ -13,7 +13,7 @@ async def post(url: str, *args, **kwargs): return data -async def Winxbin(text): +async def winxbin(text: str | dict): resp = await post(f"{BASE}api/v2/paste", data=text) if not resp["success"]: return diff --git a/WinxMusic/utils/permissions.py b/WinxMusic/utils/permissions.py index a5b0a450..bbae61a5 100644 --- a/WinxMusic/utils/permissions.py +++ b/WinxMusic/utils/permissions.py @@ -2,6 +2,7 @@ from functools import wraps from traceback import format_exc as err +from pyrogram import Client from pyrogram.errors.exceptions.forbidden_403 import ChatWriteForbidden from pyrogram.types import Message @@ -35,42 +36,43 @@ async def member_permissions(chat_id: int, user_id: int): return perms -async def authorised(func, subFunc2, client, message, *args, **kwargs): - chatID = message.chat.id +async def authorised(func: callable, sub_func2: callable, client: Client, message: Message, *args: list, + **kwargs: dict): + chat_id = message.chat.id try: await func(client, message, *args, **kwargs) except ChatWriteForbidden: - await app.leave_chat(chatID) + await app.leave_chat(chat_id) except Exception as e: logging.exception(e) try: - await message.reply_text(str(e.MESSAGE)) + await message.reply_text(str(e.__class__.__name__) + ": " + str(e)) except AttributeError: await message.reply_text(str(e)) e = err() print(str(e)) - return subFunc2 + return sub_func2 async def unauthorised( - message: Message, permission, subFunc2, bot_lacking_permission=False + message: Message, permission: str, sub_func2: callable, bot_lacking_permission=False ): - chatID = message.chat.id + chat_id = message.chat.id if bot_lacking_permission: text = ( - "I don't have the required permission to perform this action." - + f"\n**Permission:** __{permission}__" + "Eu não tenho a permissão necessária para realizar esta ação." + + f"\n**Permissão:** __{permission}__" ) else: text = ( - "You don't have the required permission to perform this action." - + f"\n**Permission:** __{permission}__" + "Você não tem a permissão necessária para realizar esta ação." + + f"\n**Permissão:** __{permission}__" ) try: await message.reply_text(text) except ChatWriteForbidden: - await app.leave_chat(chatID) - return subFunc2 + await app.leave_chat(chat_id) + return sub_func2 async def bot_permissions(chat_id: int): @@ -79,39 +81,39 @@ async def bot_permissions(chat_id: int): return await member_permissions(chat_id, bot_id) -def adminsOnly(permission): - def subFunc(func): +def admins_only(permission: str): + def sub_func(func: callable): @wraps(func) - async def subFunc2(client, message: Message, *args, **kwargs): - chatID = message.chat.id + async def sub_func2(client: Client, message: Message, *args: list, **kwargs: dict): + chat_id = message.chat.id - # Check if the bot has the required permission - bot_perms = await bot_permissions(chatID) + # check if the bot has the required permission + bot_perms = await bot_permissions(chat_id) if permission not in bot_perms: return await unauthorised( - message, permission, subFunc2, bot_lacking_permission=True + message, permission, sub_func2, bot_lacking_permission=True ) if not message.from_user: - # For anonymous admins + # for anonymous admins if message.sender_chat and message.sender_chat.id == message.chat.id: return await authorised( func, - subFunc2, + sub_func2, client, message, *args, **kwargs, ) - return await unauthorised(message, permission, subFunc2) + return await unauthorised(message, permission, sub_func2) # For admins and sudo users - userID = message.from_user.id - permissions = await member_permissions(chatID, userID) - if userID not in SUDOERS and permission not in permissions: - return await unauthorised(message, permission, subFunc2) - return await authorised(func, subFunc2, client, message, *args, **kwargs) + user_id = message.from_user.id + permissions = await member_permissions(chat_id, user_id) + if user_id not in SUDOERS and permission not in permissions: + return await unauthorised(message, permission, sub_func2) + return await authorised(func, sub_func2, client, message, *args, **kwargs) - return subFunc2 + return sub_func2 - return subFunc + return sub_func diff --git a/WinxMusic/utils/stream/queue.py b/WinxMusic/utils/stream/queue.py index 5dd49f99..fbf5ec04 100644 --- a/WinxMusic/utils/stream/queue.py +++ b/WinxMusic/utils/stream/queue.py @@ -6,17 +6,17 @@ async def put_queue( - chat_id, - original_chat_id, - file, - title, - duration, - user, - vidid, - user_id, - stream, - thumb: str = None, - forceplay: Union[bool, str] = None, + chat_id: int, + original_chat_id: int, + file: str, + title: str, + duration: str, + user: str, + vidid: str, + user_id: int, + stream: str, + thumb: str = None, + forceplay: Union[bool, str] = None, ): title = title.title() try: @@ -57,15 +57,15 @@ async def put_queue( async def put_queue_index( - chat_id, - original_chat_id, - file, - title, - duration, - user, - vidid, - stream, - forceplay: Union[bool, str] = None, + chat_id, + original_chat_id, + file, + title, + duration, + user, + vidid, + stream, + forceplay: Union[bool, str] = None, ): put = { "title": title, diff --git a/WinxMusic/utils/stream/stream.py b/WinxMusic/utils/stream/stream.py index d59d218e..0c8f7dfe 100644 --- a/WinxMusic/utils/stream/stream.py +++ b/WinxMusic/utils/stream/stream.py @@ -16,23 +16,23 @@ from WinxMusic.utils.exceptions import AssistantErr from WinxMusic.utils.inline.play import stream_markup, telegram_markup from WinxMusic.utils.inline.playlist import close_markup -from WinxMusic.utils.pastebin import Winxbin +from WinxMusic.utils.pastebin import winxbin from WinxMusic.utils.stream.queue import put_queue, put_queue_index from WinxMusic.utils.thumbnails import gen_qthumb, gen_thumb async def stream( - _, - mystic, - user_id, - result, - chat_id, - user_name, - original_chat_id, - video: Union[bool, str] = None, - streamtype: Union[bool, str] = None, - spotify: Union[bool, str] = None, - forceplay: Union[bool, str] = None, + _, + mystic, + user_id, + result, + chat_id, + user_name, + original_chat_id, + video: Union[bool, str] = None, + streamtype: Union[bool, str] = None, + spotify: Union[bool, str] = None, + forceplay: Union[bool, str] = None, ): if not result: return @@ -120,7 +120,7 @@ async def stream( if count == 0: return else: - link = await Winxbin(msg) + link = await winxbin(msg) lines = msg.count("\n") if lines >= 17: car = os.linesep.join(msg.split(os.linesep)[:17]) @@ -329,7 +329,7 @@ async def stream( if count == 0: return else: - link = await Winxbin(msg) + link = await winxbin(msg) lines = msg.count("\n") if lines >= 17: car = os.linesep.join(msg.split(os.linesep)[:17]) diff --git a/assets/queue_img.png b/assets/queue_img.png new file mode 100644 index 00000000..b3f1bfdc Binary files /dev/null and b/assets/queue_img.png differ