diff --git a/WinxMusic/__main__.py b/WinxMusic/__main__.py index a0bef27..b760adf 100644 --- a/WinxMusic/__main__.py +++ b/WinxMusic/__main__.py @@ -15,16 +15,16 @@ async def init(): if ( - not config.STRING1 - and not config.STRING2 - and not config.STRING3 - and not config.STRING4 - and not config.STRING5 - and not config.STRING6 - and not config.STRING7 - and not config.STRING8 - and not config.STRING9 - and not config.STRING10 + not config.STRING1 + and not config.STRING2 + and not config.STRING3 + and not config.STRING4 + and not config.STRING5 + and not config.STRING6 + and not config.STRING7 + and not config.STRING8 + and not config.STRING9 + and not config.STRING10 ): LOGGER(__name__).error("Assistant client variables not defined, exiting...") exit() diff --git a/WinxMusic/core/bot.py b/WinxMusic/core/bot.py index 8c21b68..fafc165 100644 --- a/WinxMusic/core/bot.py +++ b/WinxMusic/core/bot.py @@ -3,7 +3,6 @@ from pyrogram.types import BotCommand import config - from ..logging import LOGGER @@ -43,7 +42,7 @@ async def log_bot_start(self): await self.send_message( chat_id=config.LOGGER_ID, text=f"๐Ÿš€โžœ {self.mention} Bot iniciado:๐Ÿš€\n\n" - f"ID: {self.id}\nNome: {self.name}\nUsuรกrio: @{self.username}", + f"ID: {self.id}\nNome: {self.name}\nUsuรกrio: @{self.username}", ) except (errors.ChannelInvalid, errors.PeerIdInvalid): LOGGER(__name__).error( diff --git a/WinxMusic/core/call.py b/WinxMusic/core/call.py index 07478b7..9a0ce0b 100644 --- a/WinxMusic/core/call.py +++ b/WinxMusic/core/call.py @@ -6,16 +6,15 @@ import pytgcalls.types from pyrogram import Client from pyrogram.types import InlineKeyboardMarkup -from pytgcalls import PyTgCalls +from pytgcalls import PyTgCalls, filters from pytgcalls.exceptions import AlreadyJoinedError, NoActiveGroupCall -from pytgcalls.types import MediaStream -from pytgcalls.types.raw import AudioParameters, VideoParameters +from pytgcalls.types import MediaStream, ChatUpdate, GroupCallParticipant, Update from pytgcalls.types.stream import StreamAudioEnded import config -from strings import get_string from WinxMusic import LOGGER, YouTube, app from WinxMusic.misc import db +from WinxMusic.utils import get_audio_bitrate, get_video_bitrate from WinxMusic.utils.database import ( add_active_chat, add_active_video_chat, @@ -33,9 +32,11 @@ from WinxMusic.utils.inline.play import stream_markup from WinxMusic.utils.stream.autoclear import auto_clean from WinxMusic.utils.thumbnails import get_thumb +from strings import get_string autoend = {} counter = {} +AUTO_END_TIME = 1 async def _clear_(chat_id): @@ -159,59 +160,59 @@ async def stop_stream(self, chat_id: int): assistant = await group_assistant(self, chat_id) try: await _clear_(chat_id) - await assistant.leave_group_call(chat_id) + await assistant.leave_call(chat_id) except: pass async def stop_stream_force(self, chat_id: int): try: if config.STRING1: - await self.one.leave_group_call(chat_id) + await self.one.leave_call(chat_id) except: pass try: if config.STRING2: - await self.two.leave_group_call(chat_id) + await self.two.leave_call(chat_id) except: pass try: if config.STRING3: - await self.three.leave_group_call(chat_id) + await self.three.leave_call(chat_id) except: pass try: if config.STRING4: - await self.four.leave_group_call(chat_id) + await self.four.leave_call(chat_id) except: pass try: if config.STRING5: - await self.five.leave_group_call(chat_id) + await self.five.leave_call(chat_id) except: pass try: if config.STRING6: - await self.six.leave_group_call(chat_id) + await self.six.leave_call(chat_id) except: pass try: if config.STRING7: - await self.seven.leave_group_call(chat_id) + await self.seven.leave_call(chat_id) except: pass try: if config.STRING8: - await self.eight.leave_group_call(chat_id) + await self.eight.leave_call(chat_id) except: pass try: if config.STRING9: - await self.nine.leave_group_call(chat_id) + await self.nine.leave_call(chat_id) except: pass try: if config.STRING10: - await self.ten.leave_group_call(chat_id) + await self.ten.leave_call(chat_id) except: pass try: @@ -259,23 +260,19 @@ async def speedup_stream(self, chat_id: int, file_path, speed, playing): dur = int(dur) played, con_seconds = speed_converter(playing[0]["played"], speed) duration = seconds_to_min(dur) + audio_stream_quality = await get_audio_bitrate(chat_id) + video_stream_quality = await get_video_bitrate(chat_id) stream = ( MediaStream( out, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, additional_ffmpeg_parameters=f"-ss {played} -to {duration}", ) if playing[0]["streamtype"] == "video" else MediaStream( out, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), + audio_parameters=audio_stream_quality, additional_ffmpeg_parameters=f"-ss {played} -to {duration}", ) ) @@ -304,34 +301,30 @@ async def force_stop_stream(self, chat_id: int): await remove_active_video_chat(chat_id) await remove_active_chat(chat_id) try: - await assistant.leave_group_call(chat_id) + await assistant.leave_call(chat_id) except: 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) + video_stream_quality = await get_video_bitrate(chat_id) if video: stream = MediaStream( link, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, ) else: stream = MediaStream( link, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), + audio_parameters=audio_stream_quality, ) await assistant.change_stream( chat_id, @@ -340,23 +333,19 @@ async def skip_stream( async def seek_stream(self, chat_id, file_path, to_seek, duration, mode): assistant = await group_assistant(self, chat_id) + audio_stream_quality = await get_audio_bitrate(chat_id) + video_stream_quality = await get_video_bitrate(chat_id) stream = ( MediaStream( file_path, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, additional_ffmpeg_parameters=f"-ss {to_seek} -to {duration}", ) if mode == "video" else MediaStream( file_path, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), + audio_parameters=audio_stream_quality, additional_ffmpeg_parameters=f"-ss {to_seek} -to {duration}", ) ) @@ -364,55 +353,47 @@ async def seek_stream(self, chat_id, file_path, to_seek, duration, mode): async def stream_call(self, link): assistant = await group_assistant(self, config.LOGGER_ID) - await assistant.join_group_call( + await assistant.play( config.LOGGER_ID, MediaStream(link), ) await asyncio.sleep(0.2) - await assistant.leave_group_call(config.LOGGER_ID) + await assistant.leave_call(config.LOGGER_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) language = await get_lang(chat_id) + audio_stream_quality = await get_audio_bitrate(chat_id) + video_stream_quality = await get_video_bitrate(chat_id) _ = get_string(language) if video: stream = MediaStream( link, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, ) else: stream = ( MediaStream( link, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, ) if video else MediaStream( link, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), + audio_parameters=audio_stream_quality, ) ) try: - await assistant.join_group_call( + await assistant.play( chat_id, stream, ) @@ -445,11 +426,11 @@ async def change_stream(self, client, chat_id): await auto_clean(popped) if not check: await _clear_(chat_id) - return await client.leave_group_call(chat_id) + return await client.leave_call(chat_id) except: try: await _clear_(chat_id) - return await client.leave_group_call(chat_id) + return await client.leave_call(chat_id) except: return else: @@ -463,6 +444,8 @@ async def change_stream(self, client, chat_id): videoid = check[0]["vidid"] db[chat_id][0]["played"] = 0 exis = (check[0]).get("old_dur") + audio_stream_quality = await get_audio_bitrate(chat_id) + video_stream_quality = await get_video_bitrate(chat_id) if exis: db[chat_id][0]["dur"] = exis db[chat_id][0]["seconds"] = check[0]["old_second"] @@ -479,19 +462,13 @@ async def change_stream(self, client, chat_id): if video: stream = MediaStream( link, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, ) else: stream = MediaStream( link, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), + audio_parameters=audio_stream_quality, ) try: await client.change_stream(chat_id, stream) @@ -531,19 +508,13 @@ async def change_stream(self, client, chat_id): if video: stream = MediaStream( file_path, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, ) else: stream = MediaStream( file_path, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), + audio_parameters=audio_stream_quality, ) try: await client.change_stream(chat_id, stream) @@ -572,19 +543,13 @@ async def change_stream(self, client, chat_id): stream = ( MediaStream( videoid, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, ) if str(streamtype) == "video" else MediaStream( videoid, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), + audio_parameters=audio_stream_quality, ) ) try: @@ -607,19 +572,13 @@ async def change_stream(self, client, chat_id): if video: stream = MediaStream( queued, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), - video_parameters=VideoParameters.from_quality( - pytgcalls.types.VideoQuality.SD_480p - ), + audio_parameters=audio_stream_quality, + video_parameters=video_stream_quality, ) else: stream = MediaStream( queued, - audio_parameters=AudioParameters.from_quality( - pytgcalls.types.AudioQuality.HIGH - ), + audio_parameters=audio_stream_quality, ) try: await client.change_stream(chat_id, stream) @@ -721,53 +680,127 @@ async def start(self): await self.ten.start() async def decorators(self): - @self.one.on_kicked() - @self.two.on_kicked() - @self.three.on_kicked() - @self.four.on_kicked() - @self.five.on_kicked() - @self.six.on_kicked() - @self.seven.on_kicked() - @self.eight.on_kicked() - @self.nine.on_kicked() - @self.ten.on_kicked() - @self.one.on_closed_voice_chat() - @self.two.on_closed_voice_chat() - @self.three.on_closed_voice_chat() - @self.four.on_closed_voice_chat() - @self.five.on_closed_voice_chat() - @self.six.on_closed_voice_chat() - @self.seven.on_closed_voice_chat() - @self.eight.on_closed_voice_chat() - @self.nine.on_closed_voice_chat() - @self.ten.on_closed_voice_chat() - @self.one.on_left() - @self.two.on_left() - @self.three.on_left() - @self.four.on_left() - @self.five.on_left() - @self.six.on_left() - @self.seven.on_left() - @self.eight.on_left() - @self.nine.on_left() - @self.ten.on_left() + # @self.one.on_kicked() + # @self.two.on_kicked() + # @self.three.on_kicked() + # @self.four.on_kicked() + # @self.five.on_kicked() + # @self.six.on_kicked() + # @self.seven.on_kicked() + # @self.eight.on_kicked() + # @self.nine.on_kicked() + # @self.ten.on_kicked() + # @self.one.on_closed_voice_chat() + # @self.two.on_closed_voice_chat() + # @self.three.on_closed_voice_chat() + # @self.four.on_closed_voice_chat() + # @self.five.on_closed_voice_chat() + # @self.six.on_closed_voice_chat() + # @self.seven.on_closed_voice_chat() + # @self.eight.on_closed_voice_chat() + # @self.nine.on_closed_voice_chat() + # @self.ten.on_closed_voice_chat() + # @self.one.on_left() + # @self.two.on_left() + # @self.three.on_left() + # @self.four.on_left() + # @self.five.on_left() + # @self.six.on_left() + # @self.seven.on_left() + # @self.eight.on_left() + # @self.nine.on_left() + # @self.ten.on_left() + @self.one.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.two.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.three.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.four.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.five.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.six.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.seven.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.eight.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.nine.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.ten.on_update(filters.chat_update(ChatUpdate.Status.LEFT_CALL)) + @self.one.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.two.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.three.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.four.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.five.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.six.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.seven.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.eight.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.nine.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.ten.on_update(filters.chat_update(ChatUpdate.Status.CLOSED_VOICE_CHAT)) + @self.one.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.two.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.three.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.four.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.five.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.six.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.seven.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.eight.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.nine.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) + @self.ten.on_update(filters.chat_update(ChatUpdate.Status.KICKED)) async def stream_services_handler(_, chat_id: int): await self.stop_stream(chat_id) - @self.one.on_stream_end() - @self.two.on_stream_end() - @self.three.on_stream_end() - @self.four.on_stream_end() - @self.five.on_stream_end() - @self.six.on_stream_end() - @self.seven.on_stream_end() - @self.eight.on_stream_end() - @self.nine.on_stream_end() - @self.ten.on_stream_end() + # @self.one.on_stream_end() + # @self.two.on_stream_end() + # @self.three.on_stream_end() + # @self.four.on_stream_end() + # @self.five.on_stream_end() + # @self.six.on_stream_end() + # @self.seven.on_stream_end() + # @self.eight.on_stream_end() + # @self.nine.on_stream_end() + # @self.ten.on_stream_end() + @self.one.on_update(filters.stream_end) + @self.two.on_update(filters.stream_end) + @self.three.on_update(filters.stream_end) + @self.four.on_update(filters.stream_end) + @self.five.on_update(filters.stream_end) + @self.six.on_update(filters.stream_end) + @self.seven.on_update(filters.stream_end) + @self.eight.on_update(filters.stream_end) + @self.nine.on_update(filters.stream_end) + @self.ten.on_update(filters.stream_end) async def stream_end_handler(client, update: pytgcalls.types.Update): if not isinstance(update, StreamAudioEnded): return await self.change_stream(client, update.chat_id) + @self.one.on_update(filters.chat_update(GroupCallParticipant.Action.UPDATED)) + @self.two.on_update(filters.chat_update(GroupCallParticipant.Action.UPDATED)) + @self.three.on_update(filters.chat_update(GroupCallParticipant.Action.UPDATED)) + @self.four.on_update(filters.chat_update(GroupCallParticipant.Action.UPDATED)) + @self.five.on_update(filters.chat_update(GroupCallParticipant.Action.UPDATED)) + async def participants_change_handler(client, update: Update): + if not isinstance( + update, GroupCallParticipant.Action.JOINED + ) and not isinstance(update, GroupCallParticipant.Action.LEFT): + return + chat_id = update.chat_id + users = counter.get(chat_id) + if not users: + try: + got = len(await client.get_participants(chat_id)) + except: + return + counter[chat_id] = got + if got == 1: + autoend[chat_id] = datetime.now() + timedelta(minutes=AUTO_END_TIME) + return + autoend[chat_id] = {} + else: + final = ( + users + 1 + if isinstance(update, GroupCallParticipant.Action.JOINED) + else users - 1 + ) + counter[chat_id] = final + if final == 1: + autoend[chat_id] = datetime.now() + timedelta(minutes=AUTO_END_TIME) + return + autoend[chat_id] = {} + Winx = Call() diff --git a/WinxMusic/core/git.py b/WinxMusic/core/git.py index 8f0f417..cabd272 100644 --- a/WinxMusic/core/git.py +++ b/WinxMusic/core/git.py @@ -2,11 +2,10 @@ import shlex from typing import Tuple -from git import Repo from git.exc import GitCommandError, InvalidGitRepositoryError import config - +from git import Repo from ..logging import LOGGER diff --git a/WinxMusic/core/mongo.py b/WinxMusic/core/mongo.py index 321587a..a886f19 100644 --- a/WinxMusic/core/mongo.py +++ b/WinxMusic/core/mongo.py @@ -1,7 +1,6 @@ from motor.motor_asyncio import AsyncIOMotorClient from config import MONGO_DB_URI - from ..logging import LOGGER LOGGER(__name__).info("Connecting to your Mongo Database...") diff --git a/WinxMusic/core/userbot.py b/WinxMusic/core/userbot.py index e2c7f25..a4fa3c5 100644 --- a/WinxMusic/core/userbot.py +++ b/WinxMusic/core/userbot.py @@ -1,7 +1,6 @@ from pyrogram import Client import config - from ..logging import LOGGER assistants = [] diff --git a/WinxMusic/helpers/lexica_btn_parser.py b/WinxMusic/helpers/lexica_btn_parser.py index ba1fda3..b24e975 100644 --- a/WinxMusic/helpers/lexica_btn_parser.py +++ b/WinxMusic/helpers/lexica_btn_parser.py @@ -44,7 +44,7 @@ def paginate_models(page_n: int, models: list, user_id) -> list: # can only have a certain amount of buttons side by side 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)] + [ ( EqInlineKeyboardButton( "โฌ…๏ธ", callback_data=f"d.left.{modulo_page}.{user_id}" diff --git a/WinxMusic/helpers/lexica_decorators.py b/WinxMusic/helpers/lexica_decorators.py index 41d545c..bfe906b 100644 --- a/WinxMusic/helpers/lexica_decorators.py +++ b/WinxMusic/helpers/lexica_decorators.py @@ -5,7 +5,6 @@ from urllib.parse import urlsplit from config import LOGGER_ID - from .lexica_miscs import evaluate_content media_pattern = r"\b(https?://(?:(.*?)\.)?(?:instagram\.com|www\.instagram\.com|t\.co|twitter\.com|x\.com|pin\.it|pinterest\.com|in\.pinterest\.com)(?:[^\s]*))\b" diff --git a/WinxMusic/helpers/lexica_miscs.py b/WinxMusic/helpers/lexica_miscs.py index e597552..e8188bd 100644 --- a/WinxMusic/helpers/lexica_miscs.py +++ b/WinxMusic/helpers/lexica_miscs.py @@ -17,19 +17,19 @@ async def get_file(message): if not message.reply_to_message: return None if ( - message.reply_to_message.document is False - or message.reply_to_message.photo is False + message.reply_to_message.document is False + or message.reply_to_message.photo is False ): return None if ( - message.reply_to_message.document - and message.reply_to_message.document.mime_type - in ["image/png", "image/jpg", "image/jpeg"] - or message.reply_to_message.photo + message.reply_to_message.document + and message.reply_to_message.document.mime_type + in ["image/png", "image/jpg", "image/jpeg"] + or message.reply_to_message.photo ): if ( - message.reply_to_message.document - and message.reply_to_message.document.file_size > 5242880 + message.reply_to_message.document + and message.reply_to_message.document.file_size > 5242880 ): return 1 image = await message.reply_to_message.download() @@ -63,9 +63,9 @@ def get_media(message): if message.photo: media = message.photo elif ( - message.document - and message.document.mime_type in ["image/png", "image/jpg", "image/jpeg"] - and message.document.file_size < 5242880 + message.document + and message.document.mime_type in ["image/png", "image/jpg", "image/jpeg"] + and message.document.file_size < 5242880 ): media = message.document else: @@ -74,10 +74,10 @@ def get_media(message): if message.reply_to_message.photo: media = message.reply_to_message.photo elif ( - message.reply_to_message.document - and message.reply_to_message.document.mime_type - in ["image/png", "image/jpg", "image/jpeg"] - and message.reply_to_message.document.file_size < 5242880 + message.reply_to_message.document + and message.reply_to_message.document.mime_type + in ["image/png", "image/jpg", "image/jpeg"] + and message.reply_to_message.document.file_size < 5242880 ): media = message.reply_to_message.document else: diff --git a/WinxMusic/helpers/misc.py b/WinxMusic/helpers/misc.py index d6ce83e..daaf722 100644 --- a/WinxMusic/helpers/misc.py +++ b/WinxMusic/helpers/misc.py @@ -5,15 +5,15 @@ async def get_file(message): if not message.reply_to_message: return None if ( - message.reply_to_message.document is False - or message.reply_to_message.photo is False + message.reply_to_message.document is False + or message.reply_to_message.photo is False ): return None if ( - message.reply_to_message.document - and message.reply_to_message.document.mime_type - in ["image/png", "image/jpg", "image/jpeg"] - or message.reply_to_message.photo + message.reply_to_message.document + and message.reply_to_message.document.mime_type + in ["image/png", "image/jpg", "image/jpeg"] + or message.reply_to_message.photo ): image = await message.reply_to_message.download() return image diff --git a/WinxMusic/helpers/telegraph.py b/WinxMusic/helpers/telegraph.py index b470a97..e1b6803 100644 --- a/WinxMusic/helpers/telegraph.py +++ b/WinxMusic/helpers/telegraph.py @@ -21,7 +21,7 @@ def __init__(self, author_name, author_url, short_name, access_token=None): } def create_account( - self, + self, ): url = self.baseUrl + "createAccount" data = { diff --git a/WinxMusic/misc.py b/WinxMusic/misc.py index 2602600..dfb082d 100644 --- a/WinxMusic/misc.py +++ b/WinxMusic/misc.py @@ -6,7 +6,6 @@ import config from WinxMusic.core.mongo import mongodb - from .logging import LOGGER SUDOERS = filters.user() diff --git a/WinxMusic/platforms/Carbon.py b/WinxMusic/platforms/Carbon.py index 89435cb..d557de0 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 86c4d3e..00e0376 100644 --- a/WinxMusic/platforms/Telegram.py +++ b/WinxMusic/platforms/Telegram.py @@ -23,7 +23,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: @@ -64,20 +64,20 @@ async def get_duration(self, filex, file_path): return dur async def get_filepath( - self, - audio: Union[bool, str] = None, - video: Union[bool, str] = None, + self, + audio: Union[bool, str] = None, + video: Union[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" @@ -85,7 +85,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" diff --git a/WinxMusic/platforms/Youtube.py b/WinxMusic/platforms/Youtube.py index cd0b9e8..6496a66 100644 --- a/WinxMusic/platforms/Youtube.py +++ b/WinxMusic/platforms/Youtube.py @@ -65,7 +65,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: @@ -209,10 +209,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 @@ -227,15 +227,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 eca6f47..181822f 100644 --- a/WinxMusic/plugins/admins/auth.py +++ b/WinxMusic/plugins/admins/auth.py @@ -1,7 +1,6 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS, adminlist from WinxMusic import app from WinxMusic.utils import extract_user, int_to_alpha from WinxMusic.utils.database import ( @@ -12,6 +11,7 @@ ) from WinxMusic.utils.decorators import AdminActual, language from WinxMusic.utils.inline import close_markup +from config import BANNED_USERS, adminlist @app.on_message(filters.command("auth") & filters.group & ~BANNED_USERS) diff --git a/WinxMusic/plugins/admins/callback.py b/WinxMusic/plugins/admins/callback.py index 3d55a77..7a7a09b 100644 --- a/WinxMusic/plugins/admins/callback.py +++ b/WinxMusic/plugins/admins/callback.py @@ -4,17 +4,6 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup import config -from config import ( - BANNED_USERS, - SOUNCLOUD_IMG_URL, - STREAM_IMG_URL, - TELEGRAM_AUDIO_URL, - TELEGRAM_VIDEO_URL, - adminlist, - confirmer, - votemode, -) -from strings import get_string from WinxMusic import YouTube, app from WinxMusic.core.call import Winx from WinxMusic.misc import SUDOERS, db @@ -34,6 +23,17 @@ from WinxMusic.utils.inline import close_markup, stream_markup, stream_markup_timer from WinxMusic.utils.stream.autoclear import auto_clean from WinxMusic.utils.thumbnails import get_thumb +from config import ( + BANNED_USERS, + SOUNCLOUD_IMG_URL, + STREAM_IMG_URL, + TELEGRAM_AUDIO_URL, + TELEGRAM_VIDEO_URL, + adminlist, + confirmer, + votemode, +) +from strings import get_string checker = {} upvoters = {} @@ -101,8 +101,8 @@ async def del_back_playlist(client, CallbackQuery, _): mention = "๐˜‚๐—ฝ๐˜ƒ๐—ผ๐˜๐—ฒ๐˜€" else: if ( - CallbackQuery.from_user.id - in upvoters[chat_id][CallbackQuery.message.id] + CallbackQuery.from_user.id + in upvoters[chat_id][CallbackQuery.message.id] ): await CallbackQuery.answer(_["admin_38"], show_alert=True) else: diff --git a/WinxMusic/plugins/admins/loop.py b/WinxMusic/plugins/admins/loop.py index cfabd33..06ba2a9 100644 --- a/WinxMusic/plugins/admins/loop.py +++ b/WinxMusic/plugins/admins/loop.py @@ -1,11 +1,11 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app from WinxMusic.utils.database import get_loop, set_loop from WinxMusic.utils.decorators import AdminRightsCheck from WinxMusic.utils.inline import close_markup +from config import BANNED_USERS @app.on_message(filters.command(["loop", "cloop"]) & filters.group & ~BANNED_USERS) diff --git a/WinxMusic/plugins/admins/pause.py b/WinxMusic/plugins/admins/pause.py index 7f86ab0..2124891 100644 --- a/WinxMusic/plugins/admins/pause.py +++ b/WinxMusic/plugins/admins/pause.py @@ -1,12 +1,12 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS 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.inline import close_markup +from config import BANNED_USERS @app.on_message(filters.command(["pause", "cpause"]) & filters.group & ~BANNED_USERS) diff --git a/WinxMusic/plugins/admins/resume.py b/WinxMusic/plugins/admins/resume.py index 2655475..7d68446 100644 --- a/WinxMusic/plugins/admins/resume.py +++ b/WinxMusic/plugins/admins/resume.py @@ -1,12 +1,12 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS 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.inline import close_markup +from config import BANNED_USERS @app.on_message(filters.command(["resume", "cresume"]) & filters.group & ~BANNED_USERS) diff --git a/WinxMusic/plugins/admins/seek.py b/WinxMusic/plugins/admins/seek.py index cf1a3be..60bcb2b 100644 --- a/WinxMusic/plugins/admins/seek.py +++ b/WinxMusic/plugins/admins/seek.py @@ -1,12 +1,12 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS 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.inline import close_markup +from config import BANNED_USERS @app.on_message( diff --git a/WinxMusic/plugins/admins/shuffle.py b/WinxMusic/plugins/admins/shuffle.py index 05917ae..21f7db9 100644 --- a/WinxMusic/plugins/admins/shuffle.py +++ b/WinxMusic/plugins/admins/shuffle.py @@ -3,11 +3,11 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app from WinxMusic.misc import db from WinxMusic.utils.decorators import AdminRightsCheck from WinxMusic.utils.inline import close_markup +from config import BANNED_USERS @app.on_message( diff --git a/WinxMusic/plugins/admins/skip.py b/WinxMusic/plugins/admins/skip.py index ca4b795..2860287 100644 --- a/WinxMusic/plugins/admins/skip.py +++ b/WinxMusic/plugins/admins/skip.py @@ -2,7 +2,6 @@ from pyrogram.types import InlineKeyboardMarkup, Message import config -from config import BANNED_USERS from WinxMusic import YouTube, app from WinxMusic.core.call import Winx from WinxMusic.misc import db @@ -11,6 +10,7 @@ from WinxMusic.utils.inline import close_markup, stream_markup from WinxMusic.utils.stream.autoclear import auto_clean from WinxMusic.utils.thumbnails import get_thumb +from config import BANNED_USERS @app.on_message( diff --git a/WinxMusic/plugins/admins/speed.py b/WinxMusic/plugins/admins/speed.py index 21e8c9a..4a82f13 100644 --- a/WinxMusic/plugins/admins/speed.py +++ b/WinxMusic/plugins/admins/speed.py @@ -1,7 +1,6 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS, adminlist from WinxMusic import app from WinxMusic.core.call import Winx from WinxMusic.misc import SUDOERS, db @@ -9,6 +8,7 @@ from WinxMusic.utils.database import is_active_chat, is_nonadmin_chat from WinxMusic.utils.decorators.language import languageCB from WinxMusic.utils.inline import close_markup, speed_markup +from config import BANNED_USERS, adminlist checker = [] diff --git a/WinxMusic/plugins/admins/stop.py b/WinxMusic/plugins/admins/stop.py index 6fd58d7..35e9771 100644 --- a/WinxMusic/plugins/admins/stop.py +++ b/WinxMusic/plugins/admins/stop.py @@ -1,12 +1,12 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app from WinxMusic.core.call import Winx from WinxMusic.utils.database import set_loop from WinxMusic.utils.decorators import AdminRightsCheck from WinxMusic.utils.inline import close_markup +from config import BANNED_USERS @app.on_message( diff --git a/WinxMusic/plugins/admins/tagall.py b/WinxMusic/plugins/admins/tagall.py index 2ce6871..2420613 100644 --- a/WinxMusic/plugins/admins/tagall.py +++ b/WinxMusic/plugins/admins/tagall.py @@ -171,8 +171,8 @@ async def mentionall(client, message): is_admin = False else: if participant.status in ( - ChatMemberStatus.ADMINISTRATOR, - ChatMemberStatus.OWNER, + ChatMemberStatus.ADMINISTRATOR, + ChatMemberStatus.OWNER, ): is_admin = True if not is_admin: @@ -241,8 +241,8 @@ async def mention_allvc(client, message): is_admin = False else: if participant.status in ( - ChatMemberStatus.ADMINISTRATOR, - ChatMemberStatus.OWNER, + ChatMemberStatus.ADMINISTRATOR, + ChatMemberStatus.OWNER, ): is_admin = True if not is_admin: @@ -300,8 +300,8 @@ async def cancel_spam(client, message): is_admin = False else: if participant.status in ( - ChatMemberStatus.ADMINISTRATOR, - ChatMemberStatus.OWNER, + ChatMemberStatus.ADMINISTRATOR, + ChatMemberStatus.OWNER, ): is_admin = True if not is_admin: diff --git a/WinxMusic/plugins/ai/mymidjourney.py b/WinxMusic/plugins/ai/mymidjourney.py index 0f21039..a5e648a 100644 --- a/WinxMusic/plugins/ai/mymidjourney.py +++ b/WinxMusic/plugins/ai/mymidjourney.py @@ -4,10 +4,10 @@ from pyrogram import filters from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message -from config import BANNED_USERS, MIDJOURNEY_KEY from WinxMusic import LOGGER, app from WinxMusic.helpers.misc import get_text from WinxMusic.misc import AUTHORIZED_CHATS +from config import BANNED_USERS, MIDJOURNEY_KEY API_URL = "https://api.mymidjourney.ai/api/v1/midjourney" API_TIMEOUT = 120 @@ -56,7 +56,7 @@ async def create_task_process(message: Message, prompt_data): ) try: async with aiohttp.ClientSession( - timeout=aiohttp.ClientTimeout(total=API_TIMEOUT), headers=HEADERS + timeout=aiohttp.ClientTimeout(total=API_TIMEOUT), headers=HEADERS ) as session: response = await session.post( f"{API_URL}/imagine/", data={"prompt": prompt_data["prompt"]} @@ -82,7 +82,7 @@ async def get_task_process(message: Message, mj_id: str): ) try: async with aiohttp.ClientSession( - timeout=aiohttp.ClientTimeout(total=API_TIMEOUT), headers=HEADERS + timeout=aiohttp.ClientTimeout(total=API_TIMEOUT), headers=HEADERS ) as session: response = await session.get(f"{API_URL}/message/{mj_id}") data = await response.json() @@ -130,7 +130,7 @@ async def process_image_generation(message: Message, mj_id: str, prompt_data): async def download_and_send_image( - message: Message, image_url: str, buttons: list, user_id: int, reply_to_id: int + message: Message, image_url: str, buttons: list, user_id: int, reply_to_id: int ): async with aiohttp.ClientSession() as session: response = await session.get(image_url) @@ -153,7 +153,7 @@ async def task_action(message: Message, mj_id, action): f"task action for {message.from_user.id} with message_id: {mj_id} and action: {action}" ) async with aiohttp.ClientSession( - timeout=aiohttp.ClientTimeout(total=API_TIMEOUT), headers=HEADERS + timeout=aiohttp.ClientTimeout(total=API_TIMEOUT), headers=HEADERS ) as session: response = await session.post( f"{API_URL}/button/", data={"messageId": mj_id, "button": action} diff --git a/WinxMusic/plugins/ai/replicate.py b/WinxMusic/plugins/ai/replicate.py index 3620f27..981f9f6 100644 --- a/WinxMusic/plugins/ai/replicate.py +++ b/WinxMusic/plugins/ai/replicate.py @@ -1,11 +1,11 @@ -import replicate from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS +import replicate from WinxMusic import LOGGER, app from WinxMusic.helpers.misc import get_file from WinxMusic.misc import AUTHORIZED_CHATS +from config import BANNED_USERS @app.on_message( diff --git a/WinxMusic/plugins/ai/safone.py b/WinxMusic/plugins/ai/safone.py index 4ed7554..75f5ca1 100644 --- a/WinxMusic/plugins/ai/safone.py +++ b/WinxMusic/plugins/ai/safone.py @@ -1,5 +1,5 @@ -from pyrogram import * from SafoneAPI import SafoneAPI +from pyrogram import * from WinxMusic import LOGGER, app diff --git a/WinxMusic/plugins/anime/couples.py b/WinxMusic/plugins/anime/couples.py index 5039bf6..2f3a4a4 100644 --- a/WinxMusic/plugins/anime/couples.py +++ b/WinxMusic/plugins/anime/couples.py @@ -3,9 +3,9 @@ from pyrogram import filters -from config import BANNED_USERS from WinxMusic import app from WinxMusic.utils.database import get_couple, save_couple +from config import BANNED_USERS COUPLE_COMMAND = ["couple", "casal", "winxers"] PHOTO_URL = "https://telegra.ph/file/908be770f3a34834379f1.png" diff --git a/WinxMusic/plugins/anime/nekos.py b/WinxMusic/plugins/anime/nekos.py index dd20591..a740e3b 100644 --- a/WinxMusic/plugins/anime/nekos.py +++ b/WinxMusic/plugins/anime/nekos.py @@ -2,8 +2,8 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app +from config import BANNED_USERS # --------------------------------------------------------------------------------- # diff --git a/WinxMusic/plugins/anime/wifu.py b/WinxMusic/plugins/anime/wifu.py index 00051c1..0f05dee 100644 --- a/WinxMusic/plugins/anime/wifu.py +++ b/WinxMusic/plugins/anime/wifu.py @@ -4,8 +4,8 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app +from config import BANNED_USERS WIFU_COMMAND = ["wifu", "waifu"] API_ENDPOINT = "https://waifu.pics/api/sfw/waifu" diff --git a/WinxMusic/plugins/bot/help.py b/WinxMusic/plugins/bot/help.py index f88caaf..1795d60 100644 --- a/WinxMusic/plugins/bot/help.py +++ b/WinxMusic/plugins/bot/help.py @@ -3,19 +3,19 @@ from pyrogram import filters, types from pyrogram.types import InlineKeyboardMarkup, Message -from config import BANNED_USERS, START_IMG_URL, SUPPORT_CHAT -from strings import get_string, helpers from WinxMusic import app from WinxMusic.utils import help_pannel from WinxMusic.utils.database import get_lang from WinxMusic.utils.decorators.language import LanguageStart, languageCB from WinxMusic.utils.inline.help import help_back_markup, private_help_panel +from config import BANNED_USERS, START_IMG_URL, SUPPORT_CHAT +from strings import get_string, helpers @app.on_message(filters.command(["help"]) & filters.private & ~BANNED_USERS) @app.on_callback_query(filters.regex("settings_back_helper") & ~BANNED_USERS) async def helper_private( - client: app, update: Union[types.Message, types.CallbackQuery] + client: app, update: Union[types.Message, types.CallbackQuery] ): is_callback = isinstance(update, types.CallbackQuery) if is_callback: diff --git a/WinxMusic/plugins/bot/inline.py b/WinxMusic/plugins/bot/inline.py index 8417dae..4aa64f7 100644 --- a/WinxMusic/plugins/bot/inline.py +++ b/WinxMusic/plugins/bot/inline.py @@ -5,9 +5,9 @@ ) from youtubesearchpython.__future__ import VideosSearch -from config import BANNED_USERS from WinxMusic import app from WinxMusic.utils.inlinequery import answer +from config import BANNED_USERS @app.on_inline_query(~BANNED_USERS) diff --git a/WinxMusic/plugins/bot/settings.py b/WinxMusic/plugins/bot/settings.py index 760b3f6..8a9e42c 100644 --- a/WinxMusic/plugins/bot/settings.py +++ b/WinxMusic/plugins/bot/settings.py @@ -8,7 +8,6 @@ Message, ) -from config import BANNED_USERS, OWNER_ID from WinxMusic import app from WinxMusic.utils.database import ( add_nonadmin_chat, @@ -35,6 +34,7 @@ vote_mode_markup, ) from WinxMusic.utils.inline.start import private_panel +from config import BANNED_USERS, OWNER_ID @app.on_message( diff --git a/WinxMusic/plugins/bot/start.py b/WinxMusic/plugins/bot/start.py index 77f2a4f..5f052c0 100644 --- a/WinxMusic/plugins/bot/start.py +++ b/WinxMusic/plugins/bot/start.py @@ -6,8 +6,6 @@ from youtubesearchpython.__future__ import VideosSearch import config -from config import BANNED_USERS -from strings import get_string from WinxMusic import app from WinxMusic.misc import _boot_ from WinxMusic.plugins.sudo.sudoers import sudoers_list @@ -24,6 +22,8 @@ from WinxMusic.utils.decorators.language import LanguageStart from WinxMusic.utils.formatters import get_readable_time from WinxMusic.utils.inline import help_pannel, private_panel, start_panel +from config import BANNED_USERS +from strings import get_string @app.on_message(filters.command(["start"]) & filters.private & ~BANNED_USERS) @@ -45,9 +45,9 @@ async def start_pm(client, message: Message, _): return await app.send_message( chat_id=config.LOGGER_ID, text=f"{message.from_user.mention} ๐—ฎ๐—ฐ๐—ฎ๐—ฏ๐—ผ๐˜‚ ๐—ฑ๐—ฒ ๐—ถ๐—ป๐—ถ๐—ฐ๐—ถ๐—ฎ๐—ฟ ๐—ผ ๐—ฏ๐—ผ๐˜ ๐—ฝ๐—ฎ๐—ฟ๐—ฎ " - f"๐˜ƒ๐—ฒ๐—ฟ๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐—ฟ ๐—ฎ ๐—น๐—ถ๐˜€๐˜๐—ฎ ๐—ฑ๐—ฒ ๐˜€๐˜‚๐—ฑ๐—ผ๐˜€๐Ÿ”.\n\n๐—œ๐—— ๐—ฑ๐—ผ " - f"๐˜‚๐˜€๐˜‚รก๐—ฟ๐—ถ๐—ผ: {message.from_user.id}๐Ÿ†”\n๐—จ๐˜€๐˜‚รก๐—ฟ๐—ถ๐—ผ: @" - f"{message.from_user.username}๐Ÿ‘ค", + f"๐˜ƒ๐—ฒ๐—ฟ๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐—ฟ ๐—ฎ ๐—น๐—ถ๐˜€๐˜๐—ฎ ๐—ฑ๐—ฒ ๐˜€๐˜‚๐—ฑ๐—ผ๐˜€๐Ÿ”.\n\n๐—œ๐—— ๐—ฑ๐—ผ " + f"๐˜‚๐˜€๐˜‚รก๐—ฟ๐—ถ๐—ผ: {message.from_user.id}๐Ÿ†”\n๐—จ๐˜€๐˜‚รก๐—ฟ๐—ถ๐—ผ: @" + f"{message.from_user.username}๐Ÿ‘ค", ) return if name[0:3] == "inf": @@ -86,9 +86,9 @@ async def start_pm(client, message: Message, _): return await app.send_message( chat_id=config.LOGGER_ID, text=f"{message.from_user.mention} ๐—ฎ๐—ฐ๐—ฎ๐—ฏ๐—ผ๐˜‚ ๐—ฑ๐—ฒ ๐—ถ๐—ป๐—ถ๐—ฐ๐—ถ๐—ฎ๐—ฟ ๐—ผ ๐—ฏ๐—ผ๐˜ ๐—ฝ๐—ฎ๐—ฟ๐—ฎ " - f"๐˜ƒ๐—ฒ๐—ฟ๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐—ฟ ๐—ถ๐—ป๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎรงรต๐—ฒ๐˜€ ๐—ฑ๐—ฎ ๐—ฒ๐—ป๐—ฐ๐—ผ๐—บ๐—ฒ๐—ป๐—ฑ๐—ฎ ๐Ÿ“ฆ.\n\n๐—œ๐—— ๐—ฑ๐—ผ " - f"๐˜‚๐˜€๐˜‚รก๐—ฟ๐—ถ๐—ผ: {message.from_user.id} ๐Ÿ†”\n๐—จ๐˜€๐˜‚รก๐—ฟ๐—ถ๐—ผ: @" - f"{message.from_user.username} ๐Ÿ“›", + f"๐˜ƒ๐—ฒ๐—ฟ๐—ถ๐—ณ๐—ถ๐—ฐ๐—ฎ๐—ฟ ๐—ถ๐—ป๐—ณ๐—ผ๐—ฟ๐—บ๐—ฎรงรต๐—ฒ๐˜€ ๐—ฑ๐—ฎ ๐—ฒ๐—ป๐—ฐ๐—ผ๐—บ๐—ฒ๐—ป๐—ฑ๐—ฎ ๐Ÿ“ฆ.\n\n๐—œ๐—— ๐—ฑ๐—ผ " + f"๐˜‚๐˜€๐˜‚รก๐—ฟ๐—ถ๐—ผ: {message.from_user.id} ๐Ÿ†”\n๐—จ๐˜€๐˜‚รก๐—ฟ๐—ถ๐—ผ: @" + f"{message.from_user.username} ๐Ÿ“›", ) else: out = private_panel(_) @@ -101,8 +101,8 @@ async def start_pm(client, message: Message, _): return await app.send_message( chat_id=config.LOGGER_ID, text=f"๐—ข {message.from_user.mention} ๐—ฎ๐—ฐ๐—ฎ๐—ฏ๐—ผ๐˜‚ ๐—ฑ๐—ฒ ๐—ถ๐—ป๐—ถ๐—ฐ๐—ถ๐—ฎ๐—ฟ ๐—ผ ๐—ฏ๐—ผ๐˜. ๐Ÿš€\n\n๐—œ๐—— ๐—ฑ๐—ผ " - f"๐˜‚๐˜€๐˜‚๐—ฎฬ๐—ฟ๐—ถ๐—ผ: {message.from_user.id} ๐Ÿ†”\n๐—จ๐˜€๐˜‚๐—ฎฬ๐—ฟ๐—ถ๐—ผ:<" - f"/b> @{message.from_user.username} ๐Ÿ“›", + f"๐˜‚๐˜€๐˜‚๐—ฎฬ๐—ฟ๐—ถ๐—ผ: {message.from_user.id} ๐Ÿ†”\n๐—จ๐˜€๐˜‚๐—ฎฬ๐—ฟ๐—ถ๐—ผ:<" + f"/b> @{message.from_user.username} ๐Ÿ“›", ) diff --git a/WinxMusic/plugins/lexica/deprecated_image.py b/WinxMusic/plugins/lexica/deprecated_image.py index d3d8f1b..1b98215 100644 --- a/WinxMusic/plugins/lexica/deprecated_image.py +++ b/WinxMusic/plugins/lexica/deprecated_image.py @@ -6,10 +6,10 @@ Message, ) -from config import BANNED_USERS from WinxMusic import LOGGER, app from WinxMusic.helpers.lexica_api import image_generation from WinxMusic.helpers.misc import ImageModels, get_text +from config import BANNED_USERS # -------------------------------------------------------------------------------------- # Image AI @@ -55,7 +55,7 @@ def generate_buttons(user_id): ) for model in ImageModels ] - return [buttons[i : i + 2] for i in range(0, len(buttons), 2)] + return [buttons[i: i + 2] for i in range(0, len(buttons), 2)] @app.on_callback_query(filters.regex("^draw.(.*)")) diff --git a/WinxMusic/plugins/lexica/draw.py b/WinxMusic/plugins/lexica/draw.py index c45f8f9..530a479 100644 --- a/WinxMusic/plugins/lexica/draw.py +++ b/WinxMusic/plugins/lexica/draw.py @@ -2,11 +2,11 @@ from pyrogram import Client, filters from pyrogram import types as t -from config import BANNED_USERS from WinxMusic import app from WinxMusic.helpers.lexica_api import lexica_image_generation from WinxMusic.helpers.lexica_btn_parser import paginate_models from WinxMusic.helpers.lexica_miscs import get_text +from config import BANNED_USERS Database = {} Models = ApiClient().models["models"]["image"] diff --git a/WinxMusic/plugins/lexica/image_reverse.py b/WinxMusic/plugins/lexica/image_reverse.py index 7472296..9b4d14f 100644 --- a/WinxMusic/plugins/lexica/image_reverse.py +++ b/WinxMusic/plugins/lexica/image_reverse.py @@ -3,11 +3,11 @@ from pyrogram import Client, filters from pyrogram import types as t -from config import BANNED_USERS from WinxMusic import app from WinxMusic.helpers.lexica_api import lexica_reverse_image_search from WinxMusic.helpers.lexica_miscs import get_file from WinxMusic.helpers.telegraph import GraphClient, upload_to_telegraph +from config import BANNED_USERS @app.on_message( diff --git a/WinxMusic/plugins/lexica/images.py b/WinxMusic/plugins/lexica/images.py index 17fb0b4..4d51520 100644 --- a/WinxMusic/plugins/lexica/images.py +++ b/WinxMusic/plugins/lexica/images.py @@ -35,9 +35,9 @@ async def search_images(_: Client, m: t.Message): await m.reply_media_group(media, quote=True) await reply.delete() except ( - errors.ExternalUrlInvalid, - errors.WebpageCurlFailed, - errors.WebpageMediaEmpty, + errors.ExternalUrlInvalid, + errors.WebpageCurlFailed, + errors.WebpageMediaEmpty, ) as e: print(e) return await reply.edit("Ran into an error.") diff --git a/WinxMusic/plugins/lexica/llm.py b/WinxMusic/plugins/lexica/llm.py index 22f062e..3aa5a04 100644 --- a/WinxMusic/plugins/lexica/llm.py +++ b/WinxMusic/plugins/lexica/llm.py @@ -2,11 +2,11 @@ from pyrogram import filters from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message -from config import BANNED_USERS -from strings import get_string from WinxMusic import LOGGER, app from WinxMusic.helpers.misc import get_text from WinxMusic.utils import get_lang +from config import BANNED_USERS +from strings import get_string main_prompt = "Vocรช รฉ a AI do Clube das Winx. Ao responder, por favor, chame o usuรกrio pelo nome. {0}" prompt_db = {} @@ -23,7 +23,7 @@ def build_model_mapping(): mapping = {} for attr_name in dir(languageModels): if not attr_name.startswith("__") and isinstance( - getattr(languageModels, attr_name), dict + getattr(languageModels, attr_name), dict ): model_attr = getattr(languageModels, attr_name) mapping[model_attr["name"]] = model_attr @@ -67,7 +67,7 @@ def generate_text_buttons(user_id): for model, model_id in models.items() ] - return [buttons[i : i + 2] for i in range(0, len(buttons), 2)] + return [buttons[i: i + 2] for i in range(0, len(buttons), 2)] @app.on_callback_query(filters.regex(r"^llm_") & ~BANNED_USERS) diff --git a/WinxMusic/plugins/lexica/upscale.py b/WinxMusic/plugins/lexica/upscale.py index 09e029b..2e9a9dd 100644 --- a/WinxMusic/plugins/lexica/upscale.py +++ b/WinxMusic/plugins/lexica/upscale.py @@ -3,10 +3,10 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app from WinxMusic.helpers.lexica_api import upscale_image from WinxMusic.helpers.misc import get_file +from config import BANNED_USERS @app.on_message( diff --git a/WinxMusic/plugins/misc/autoleave.py b/WinxMusic/plugins/misc/autoleave.py index d283a5d..6785d5b 100644 --- a/WinxMusic/plugins/misc/autoleave.py +++ b/WinxMusic/plugins/misc/autoleave.py @@ -27,8 +27,8 @@ async def auto_leave(): ChatType.CHANNEL, ]: if ( - i.chat.id != config.LOGGER_ID - and i.chat.id != -1001621792868 + i.chat.id != config.LOGGER_ID + and i.chat.id != -1001621792868 ): if left == 20: continue diff --git a/WinxMusic/plugins/misc/broadcast.py b/WinxMusic/plugins/misc/broadcast.py index 48d4fa4..875c4b5 100644 --- a/WinxMusic/plugins/misc/broadcast.py +++ b/WinxMusic/plugins/misc/broadcast.py @@ -12,7 +12,6 @@ UserIsBlocked, ) -from config import OWNER_ID, adminlist from WinxMusic import app from WinxMusic.misc import SUDOERS from WinxMusic.utils.database import ( @@ -25,6 +24,7 @@ ) from WinxMusic.utils.decorators.language import language from WinxMusic.utils.formatters import alpha_to_int +from config import OWNER_ID, adminlist IS_BROADCASTING = False @@ -255,7 +255,7 @@ async def auto_clean(): if chat_id not in adminlist: adminlist[chat_id] = [] async for user in app.get_chat_members( - chat_id, filter=ChatMembersFilter.ADMINISTRATORS + chat_id, filter=ChatMembersFilter.ADMINISTRATORS ): if user.privileges.can_manage_video_chats: adminlist[chat_id].append(user.user.id) diff --git a/WinxMusic/plugins/play/channel.py b/WinxMusic/plugins/play/channel.py index 9bf3513..eb2d15d 100644 --- a/WinxMusic/plugins/play/channel.py +++ b/WinxMusic/plugins/play/channel.py @@ -2,10 +2,10 @@ from pyrogram.enums import ChatMembersFilter, ChatMemberStatus, ChatType from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app from WinxMusic.utils.database import set_cmode from WinxMusic.utils.decorators.admins import AdminActual +from config import BANNED_USERS @app.on_message(filters.command(["channelplay"]) & filters.group & ~BANNED_USERS) @@ -36,7 +36,7 @@ async def playmode_(client, message: Message, _): return await message.reply_text(_["cplay_5"]) try: async for user in app.get_chat_members( - chat.id, filter=ChatMembersFilter.ADMINISTRATORS + chat.id, filter=ChatMembersFilter.ADMINISTRATORS ): if user.status == ChatMemberStatus.OWNER: cusn = user.user.username diff --git a/WinxMusic/plugins/play/live.py b/WinxMusic/plugins/play/live.py index 66aa10c..da907f0 100644 --- a/WinxMusic/plugins/play/live.py +++ b/WinxMusic/plugins/play/live.py @@ -1,10 +1,10 @@ from pyrogram import filters -from config import BANNED_USERS from WinxMusic import YouTube, app from WinxMusic.utils.channelplay import get_channeplayCB from WinxMusic.utils.decorators.language import languageCB from WinxMusic.utils.stream.stream import stream +from config import BANNED_USERS @app.on_callback_query(filters.regex("LiveStream") & ~BANNED_USERS) diff --git a/WinxMusic/plugins/play/play.py b/WinxMusic/plugins/play/play.py index fb194b3..ad381d7 100644 --- a/WinxMusic/plugins/play/play.py +++ b/WinxMusic/plugins/play/play.py @@ -7,7 +7,6 @@ from pytgcalls.exceptions import NoActiveGroupCall import config -from config import BANNED_USERS, lyrical from WinxMusic import Apple, Resso, SoundCloud, Spotify, Telegram, YouTube, app from WinxMusic.core.call import Winx from WinxMusic.utils import seconds_to_min, time_to_seconds @@ -24,6 +23,7 @@ ) from WinxMusic.utils.logger import play_logs from WinxMusic.utils.stream.stream import stream +from config import BANNED_USERS, lyrical @app.on_message( @@ -44,15 +44,15 @@ ) @PlayWrapper async def play_commnd( - client, - message: Message, - _, - chat_id, - video, - channel, - playmode, - url, - fplay, + client, + message: Message, + _, + chat_id, + video, + channel, + playmode, + url, + fplay, ): chat = await app.get_chat(message.chat.id) me = await app.get_me() @@ -132,6 +132,7 @@ async def play_commnd( forceplay=fplay, ) except Exception as e: + print(e) ex_type = type(e).__name__ err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type) return await mystic.edit_text(err) @@ -176,6 +177,7 @@ async def play_commnd( forceplay=fplay, ) except Exception as e: + print(e) ex_type = type(e).__name__ err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type) return await mystic.edit_text(err) @@ -309,6 +311,7 @@ async def play_commnd( forceplay=fplay, ) except Exception as e: + print(e) ex_type = type(e).__name__ err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type) return await mystic.edit_text(err) @@ -339,6 +342,7 @@ async def play_commnd( forceplay=fplay, ) except Exception as e: + print(e) ex_type = type(e).__name__ err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type) return await mystic.edit_text(err) @@ -395,6 +399,7 @@ async def play_commnd( forceplay=fplay, ) except Exception as e: + print(e) ex_type = type(e).__name__ err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type) return await mystic.edit_text(err) @@ -522,6 +527,7 @@ async def play_music(client, CallbackQuery, _): forceplay=ffplay, ) except Exception as e: + print(e) ex_type = type(e).__name__ err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type) return await mystic.edit_text(err) @@ -622,6 +628,7 @@ async def play_playlists_command(client, CallbackQuery, _): forceplay=ffplay, ) except Exception as e: + print(e) ex_type = type(e).__name__ err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type) return await mystic.edit_text(err) diff --git a/WinxMusic/plugins/play/playmode.py b/WinxMusic/plugins/play/playmode.py index a61e8ed..ddecfd3 100644 --- a/WinxMusic/plugins/play/playmode.py +++ b/WinxMusic/plugins/play/playmode.py @@ -1,11 +1,11 @@ from pyrogram import filters from pyrogram.types import InlineKeyboardMarkup, Message -from config import BANNED_USERS from WinxMusic import app from WinxMusic.utils.database import get_playmode, get_playtype, is_nonadmin_chat from WinxMusic.utils.decorators import language from WinxMusic.utils.inline.settings import playmode_users_markup +from config import BANNED_USERS @app.on_message(filters.command(["playmode", "mode"]) & filters.group & ~BANNED_USERS) diff --git a/WinxMusic/plugins/sudo/block.py b/WinxMusic/plugins/sudo/block.py index 586f2ab..7daf80a 100644 --- a/WinxMusic/plugins/sudo/block.py +++ b/WinxMusic/plugins/sudo/block.py @@ -1,12 +1,12 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app from WinxMusic.misc import SUDOERS from WinxMusic.utils.database import add_gban_user, remove_gban_user from WinxMusic.utils.decorators.language import language from WinxMusic.utils.extraction import extract_user +from config import BANNED_USERS @app.on_message(filters.command(["block"]) & SUDOERS) diff --git a/WinxMusic/plugins/sudo/gban.py b/WinxMusic/plugins/sudo/gban.py index ff9d5f0..4a2e20e 100644 --- a/WinxMusic/plugins/sudo/gban.py +++ b/WinxMusic/plugins/sudo/gban.py @@ -4,7 +4,6 @@ from pyrogram.errors import FloodWait from pyrogram.types import Message -from config import BANNED_USERS from WinxMusic import app from WinxMusic.misc import SUDOERS from WinxMusic.utils import get_readable_time @@ -18,6 +17,7 @@ ) from WinxMusic.utils.decorators.language import language from WinxMusic.utils.extraction import extract_user +from config import BANNED_USERS @app.on_message(filters.command(["gban", "globalban"]) & SUDOERS) diff --git a/WinxMusic/plugins/sudo/maintenance.py b/WinxMusic/plugins/sudo/maintenance.py index 10ae948..a0bdc9b 100644 --- a/WinxMusic/plugins/sudo/maintenance.py +++ b/WinxMusic/plugins/sudo/maintenance.py @@ -1,7 +1,6 @@ from pyrogram import filters from pyrogram.types import Message -from strings import get_string from WinxMusic import app from WinxMusic.misc import SUDOERS from WinxMusic.utils.database import ( @@ -10,6 +9,7 @@ maintenance_off, maintenance_on, ) +from strings import get_string @app.on_message(filters.command(["maintenance"]) & SUDOERS) diff --git a/WinxMusic/plugins/sudo/restart.py b/WinxMusic/plugins/sudo/restart.py index c04cdd7..fe7e9c4 100644 --- a/WinxMusic/plugins/sudo/restart.py +++ b/WinxMusic/plugins/sudo/restart.py @@ -62,7 +62,7 @@ async def update_(client, message, _): updates = "" 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], ) for info in repo.iter_commits(f"HEAD..origin/{config.UPSTREAM_BRANCH}"): updates += f"โžฃ #{info.count()}: {info.summary} ส™ส -> {info.author}\n\t\t\t\tโžฅ ๐—–๐—ผ๐—บ๐—ฝ๐—ฟ๐—ผ๐—บ๐—ฒ๐˜๐—ถ๐—ฑ๐—ผ ๐—ฒ๐—บ : {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" diff --git a/WinxMusic/plugins/sudo/sudoers.py b/WinxMusic/plugins/sudo/sudoers.py index 75c44a4..1cf167a 100644 --- a/WinxMusic/plugins/sudo/sudoers.py +++ b/WinxMusic/plugins/sudo/sudoers.py @@ -1,13 +1,13 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS, OWNER_ID from WinxMusic import app from WinxMusic.misc import SUDOERS from WinxMusic.utils.database import add_sudo, remove_sudo from WinxMusic.utils.decorators.language import language from WinxMusic.utils.extraction import extract_user from WinxMusic.utils.inline import close_markup +from config import BANNED_USERS, OWNER_ID @app.on_message(filters.command(["addsudo"]) & filters.user(OWNER_ID)) diff --git a/WinxMusic/plugins/tools/active.py b/WinxMusic/plugins/tools/active.py index 2a230d5..2c243a8 100644 --- a/WinxMusic/plugins/tools/active.py +++ b/WinxMusic/plugins/tools/active.py @@ -79,7 +79,8 @@ async def activevc(_, message: Message): @app.on_message(filters.command(["activev", "activevideo"]) & SUDOERS) async def activevi_(_, message: Message): - mystic = await message.reply_text("โžœ ๐Ÿ”„ ๐—•๐˜‚๐˜€๐—ฐ๐—ฎ๐—ป๐—ฑ๐—ผ ๐—น๐—ถ๐˜€๐˜๐—ฎ ๐—ฑ๐—ฒ ๐—ฐ๐—ต๐—ฎ๐˜๐˜€ ๐—ฑ๐—ฒ ๐˜ƒ๐—ถฬ๐—ฑ๐—ฒ๐—ผ ๐—ฎ๐˜๐—ถ๐˜ƒ๐—ผ๐˜€...") + mystic = await message.reply_text( + "โžœ ๐Ÿ”„ ๐—•๐˜‚๐˜€๐—ฐ๐—ฎ๐—ป๐—ฑ๐—ผ ๐—น๐—ถ๐˜€๐˜๐—ฎ ๐—ฑ๐—ฒ ๐—ฐ๐—ต๐—ฎ๐˜๐˜€ ๐—ฑ๐—ฒ ๐˜ƒ๐—ถฬ๐—ฑ๐—ฒ๐—ผ ๐—ฎ๐˜๐—ถ๐˜ƒ๐—ผ๐˜€...") served_chats = await get_active_video_chats() text = "" j = 0 diff --git a/WinxMusic/plugins/tools/ccbin.py b/WinxMusic/plugins/tools/ccbin.py index 1309790..54f6ef1 100644 --- a/WinxMusic/plugins/tools/ccbin.py +++ b/WinxMusic/plugins/tools/ccbin.py @@ -1,5 +1,5 @@ -from pyrogram import * from SafoneAPI import SafoneAPI +from pyrogram import * from ... import * diff --git a/WinxMusic/plugins/tools/deepai.py b/WinxMusic/plugins/tools/deepai.py index 0259564..bbe315b 100644 --- a/WinxMusic/plugins/tools/deepai.py +++ b/WinxMusic/plugins/tools/deepai.py @@ -5,6 +5,8 @@ from WinxMusic import app api_key = "64102a85-4dbd-4d42-af48-16fe1f31f452" + + # api_key = "995e3267-53f1-496e-82e3-39754eab99dc" @@ -84,5 +86,4 @@ async def deepchat(app: app, message): except Exception as e: await message.reply_text(f"แด‡ส€ส€แดส€: {e}") - ## diff --git a/WinxMusic/plugins/tools/dev.py b/WinxMusic/plugins/tools/dev.py index 45cb137..81bc730 100644 --- a/WinxMusic/plugins/tools/dev.py +++ b/WinxMusic/plugins/tools/dev.py @@ -10,8 +10,8 @@ from pyrogram import filters from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message -from config import OWNER_ID from WinxMusic import app +from config import OWNER_ID async def aexec(code, client, message): diff --git a/WinxMusic/plugins/tools/imposter.py b/WinxMusic/plugins/tools/imposter.py index 5b74e88..58a2e1b 100644 --- a/WinxMusic/plugins/tools/imposter.py +++ b/WinxMusic/plugins/tools/imposter.py @@ -28,9 +28,9 @@ async def chk_usr(_, message: Message): ) msg = "" if ( - usernamebefore != message.from_user.username - or first_name != message.from_user.first_name - or lastname_before != message.from_user.last_name + usernamebefore != message.from_user.username + or first_name != message.from_user.first_name + or lastname_before != message.from_user.last_name ): msg += f""" ๐Ÿ”น ๐—œ๐— ๐—ฃ๐—ข๐—ฆ๐—ง๐—ข๐—ฅ ๐——๐—˜๐—ง๐—˜๐—–๐—ง๐—”๐——๐—ข ๐Ÿ‘€: diff --git a/WinxMusic/plugins/tools/language.py b/WinxMusic/plugins/tools/language.py index bfdbccb..b4aa494 100644 --- a/WinxMusic/plugins/tools/language.py +++ b/WinxMusic/plugins/tools/language.py @@ -2,11 +2,11 @@ from pyrogram import filters from pyrogram.types import InlineKeyboardButton, Message -from config import BANNED_USERS -from strings import get_string, languages_present from WinxMusic import app from WinxMusic.utils.database import get_lang, set_lang from WinxMusic.utils.decorators import ActualAdminCB, language, languageCB +from config import BANNED_USERS +from strings import get_string, languages_present def lanuages_keyboard(_): diff --git a/WinxMusic/plugins/tools/ping.py b/WinxMusic/plugins/tools/ping.py index 1364f77..3b90c6e 100644 --- a/WinxMusic/plugins/tools/ping.py +++ b/WinxMusic/plugins/tools/ping.py @@ -3,12 +3,12 @@ from pyrogram import filters from pyrogram.types import Message -from config import BANNED_USERS, PING_IMG_URL from WinxMusic import app from WinxMusic.core.call import Winx from WinxMusic.utils import bot_sys_stats from WinxMusic.utils.decorators.language import language from WinxMusic.utils.inline import supp_markup +from config import BANNED_USERS, PING_IMG_URL @app.on_message(filters.command(["ping", "alive"]) & ~BANNED_USERS) diff --git a/WinxMusic/plugins/tools/queue.py b/WinxMusic/plugins/tools/queue.py index 9926240..f9f9610 100644 --- a/WinxMusic/plugins/tools/queue.py +++ b/WinxMusic/plugins/tools/queue.py @@ -6,13 +6,13 @@ from pyrogram.types import CallbackQuery, InputMediaPhoto, Message import config -from config import BANNED_USERS from WinxMusic import app from WinxMusic.misc import db from WinxMusic.utils import WinxBin, get_channeplayCB, 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.inline import queue_back_markup, queue_markup +from config import BANNED_USERS basic = {} diff --git a/WinxMusic/plugins/tools/reload.py b/WinxMusic/plugins/tools/reload.py index 0417768..6acab7c 100644 --- a/WinxMusic/plugins/tools/reload.py +++ b/WinxMusic/plugins/tools/reload.py @@ -5,13 +5,13 @@ from pyrogram.enums import ChatMembersFilter, ChatMemberStatus from pyrogram.types import CallbackQuery, Message -from config import BANNED_USERS, adminlist, lyrical from WinxMusic import app from WinxMusic.core.call import Winx from WinxMusic.misc import db from WinxMusic.utils.database import get_assistant, get_authuser_names, get_cmode from WinxMusic.utils.decorators import ActualAdminCB, AdminActual, language from WinxMusic.utils.formatters import alpha_to_int, get_readable_time +from config import BANNED_USERS, adminlist, lyrical rel = {} @@ -31,7 +31,7 @@ async def reload_admin_cache(client, message: Message, _): return await message.reply_text(_["reload_1"].format(left)) adminlist[message.chat.id] = [] async for user in app.get_chat_members( - message.chat.id, filter=ChatMembersFilter.ADMINISTRATORS + message.chat.id, filter=ChatMembersFilter.ADMINISTRATORS ): if user.status == ChatMemberStatus.ADMINISTRATOR: adminlist[message.chat.id].append(user.user.id) diff --git a/WinxMusic/plugins/tools/stats.py b/WinxMusic/plugins/tools/stats.py index 560f2e7..f3956b3 100644 --- a/WinxMusic/plugins/tools/stats.py +++ b/WinxMusic/plugins/tools/stats.py @@ -9,7 +9,6 @@ from pytgcalls.__version__ import __version__ as pytgver import config -from config import BANNED_USERS from WinxMusic import app from WinxMusic.core.userbot import assistants from WinxMusic.misc import SUDOERS, mongodb @@ -17,6 +16,7 @@ from WinxMusic.utils.database import get_served_chats, get_served_users, get_sudoers from WinxMusic.utils.decorators.language import language, languageCB from WinxMusic.utils.inline.stats import back_stats_buttons, stats_buttons +from config import BANNED_USERS @app.on_message(filters.command(["stats", "gstats"]) & filters.group & ~BANNED_USERS) @@ -85,7 +85,7 @@ async def bot_stats(client, CallbackQuery, _): await CallbackQuery.edit_message_text(_["gstats_1"].format(app.mention)) p_core = psutil.cpu_count(logical=False) t_core = psutil.cpu_count(logical=True) - ram = str(round(psutil.virtual_memory().total / (1024.0**3))) + " ษขส™" + ram = str(round(psutil.virtual_memory().total / (1024.0 ** 3))) + " ษขส™" try: cpu_freq = psutil.cpu_freq().current if cpu_freq >= 1000: @@ -95,9 +95,9 @@ async def bot_stats(client, CallbackQuery, _): except: cpu_freq = "๐—™๐—ฎ๐—น๐—ต๐—ฎ ๐—ฎ๐—ผ ๐—ฏ๐˜‚๐˜€๐—ฐ๐—ฎ๐—ฟ ๐Ÿšซ" hdd = psutil.disk_usage("/") - total = hdd.total / (1024.0**3) - used = hdd.used / (1024.0**3) - free = hdd.free / (1024.0**3) + total = hdd.total / (1024.0 ** 3) + used = hdd.used / (1024.0 ** 3) + free = hdd.free / (1024.0 ** 3) call = await mongodb.command("dbstats") datasize = call["dataSize"] / 1024 storage = call["storageSize"] / 1024 diff --git a/WinxMusic/plugins/tools/telegraph.py b/WinxMusic/plugins/tools/telegraph.py index 6fee84f..3c72220 100644 --- a/WinxMusic/plugins/tools/telegraph.py +++ b/WinxMusic/plugins/tools/telegraph.py @@ -51,8 +51,8 @@ async def upscale_image(client, message): message.chat.id, photo="upscaled_image.png", caption=f"**โžฒ ๐€๐ช๐ฎ๐ข ๐ž๐ฌ๐ญ๐šฬ ๐จ ๐ฌ๐ž๐ฎ ๐ฅ๐ข๐ง๐ค ๐๐จ ๐“๐ž๐ฅ๐ž๐ ๐ซ๐š๐ฉ๐ก ๐ฉ๐š๐ซ๐š ๐š ๐Ÿ๐จ๐ญ๐จ ๐ž๐ฆ " - f"๐‡๐ƒ.**\n\n**เน ๐•๐จ๐œ๐žฬ‚ ๐ฉ๐จ๐๐ž ๐œ๐จ๐ฉ๐ข๐š๐ซ ๐œ๐ฅ๐ข๐œ๐š๐ง๐๐จ ๐š๐ช๐ฎ๐ข: **\n\n" - f"**โ€ฃ** `{button_url}`\n\n**เน ๐๐จ๐ซ @{app.username}**", + f"๐‡๐ƒ.**\n\n**เน ๐•๐จ๐œ๐žฬ‚ ๐ฉ๐จ๐๐ž ๐œ๐จ๐ฉ๐ข๐š๐ซ ๐œ๐ฅ๐ข๐œ๐š๐ง๐๐จ ๐š๐ช๐ฎ๐ข: **\n\n" + f"**โ€ฃ** `{button_url}`\n\n**เน ๐๐จ๐ซ @{app.username}**", reply_markup=reply_markup, ) diff --git a/WinxMusic/plugins/tools/translate.py b/WinxMusic/plugins/tools/translate.py index b7e937a..799c420 100644 --- a/WinxMusic/plugins/tools/translate.py +++ b/WinxMusic/plugins/tools/translate.py @@ -1,8 +1,8 @@ from gpytranslate import Translator from pyrogram import filters -from config import BANNED_USERS from WinxMusic import app +from config import BANNED_USERS # ------------------------------------------------------------------------------- # @@ -40,5 +40,4 @@ async def translate(_, message) -> None: reply = f"๐—ง๐—ฟ๐—ฎ๐—ฑ๐˜‚๐˜‡๐—ถ๐—ฑ๐—ผ ๐—ฑ๐—ฒ {source} ๐ŸŒ ๐—ฝ๐—ฎ๐—ฟ๐—ฎ {dest}:\n" f"`{translation.text}`" await message.reply_text(reply) - # ------------------------------------------------------------------------------- # diff --git a/WinxMusic/utils/database/chats_db.py b/WinxMusic/utils/database/chats_db.py index 73a45d2..46fac25 100644 --- a/WinxMusic/utils/database/chats_db.py +++ b/WinxMusic/utils/database/chats_db.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Union +from typing import Any, Dict, Union from WinxMusic.core.mongo import mongodb @@ -32,4 +32,3 @@ async def remove_served_chat(chat_id: int): async def get_chat(chat_id: int) -> Union[Dict[str, Any], None]: return await chats_db.find_one({"chat_id": chat_id}) - diff --git a/WinxMusic/utils/database/database.py b/WinxMusic/utils/database/database.py index 160560e..30c2f4d 100644 --- a/WinxMusic/utils/database/database.py +++ b/WinxMusic/utils/database/database.py @@ -1,6 +1,9 @@ from typing import Any, Dict, List, Union +from pytgcalls.types import AudioQuality, VideoQuality + from WinxMusic.core.mongo import mongodb +from config import PRIVATE_BOT_MODE authdb = mongodb.adminauth authuserdb = mongodb.authuser @@ -35,6 +38,9 @@ playtype = {} skipmode = {} +audio = {} +video = {} + async def is_skipmode(chat_id: int) -> bool: mode = skipmode.get(chat_id) @@ -598,3 +604,38 @@ async def impo_on(chat_id: int) -> bool: async def impo_off(chat_id: int): await impdb.delete_one({"chat_id_toggle": chat_id}) + + +async def get_audio_bitrate(chat_id: int) -> AudioQuality: + mode = audio.get(chat_id) + if not mode: + return AudioQuality.MEDIUM + if str(mode) == "STUDIO": + return AudioQuality.STUDIO + elif str(mode) == "HIGH": + return AudioQuality.HIGH + elif str(mode) == "MEDIUM": + return AudioQuality.MEDIUM + elif str(mode) == "LOW": + return AudioQuality.LOW + + +async def get_video_bitrate(chat_id: int) -> VideoQuality: + mode = video.get(chat_id) + if not mode: + if PRIVATE_BOT_MODE == str(True): + return VideoQuality.SD_480p + else: + return VideoQuality.SD_480p + if str(mode) == "UHD_4K": + return VideoQuality.UHD_4K + elif str(mode) == "QHD_2K": + return VideoQuality.QHD_2K + elif str(mode) == "FHD_1080p": + return VideoQuality.FHD_1080p + elif str(mode) == "HD_720p": + return VideoQuality.HD_720p + elif str(mode) == "SD_480p": + return VideoQuality.SD_480p + elif str(mode) == "SD_360p": + return VideoQuality.SD_360p diff --git a/WinxMusic/utils/database/users_db.py b/WinxMusic/utils/database/users_db.py index ee941f9..8895ffa 100644 --- a/WinxMusic/utils/database/users_db.py +++ b/WinxMusic/utils/database/users_db.py @@ -28,4 +28,4 @@ async def remove_served_user(user_id: int): is_served = await is_served_user(user_id) if not is_served: return - return await users_db.delete_one({"user_id": user_id}) \ No newline at end of file + return await users_db.delete_one({"user_id": user_id}) diff --git a/WinxMusic/utils/decorators/admins.py b/WinxMusic/utils/decorators/admins.py index e6979ee..db1d121 100644 --- a/WinxMusic/utils/decorators/admins.py +++ b/WinxMusic/utils/decorators/admins.py @@ -1,8 +1,6 @@ from pyrogram.enums import ChatMemberStatus, ChatType from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup -from config import SUPPORT_CHAT, adminlist, confirmer -from strings import get_string from WinxMusic import app from WinxMusic.misc import SUDOERS, db from WinxMusic.utils.database import ( @@ -15,7 +13,8 @@ is_nonadmin_chat, is_skipmode, ) - +from config import SUPPORT_CHAT, adminlist, confirmer +from strings import get_string from ..formatters import int_to_alpha diff --git a/WinxMusic/utils/decorators/language.py b/WinxMusic/utils/decorators/language.py index 0cc6d20..5d0035d 100644 --- a/WinxMusic/utils/decorators/language.py +++ b/WinxMusic/utils/decorators/language.py @@ -1,8 +1,8 @@ -from config import SUPPORT_CHAT -from strings import get_string from WinxMusic import app from WinxMusic.misc import SUDOERS from WinxMusic.utils.database import get_lang, is_maintenance +from config import SUPPORT_CHAT +from strings import get_string def language(mystic): diff --git a/WinxMusic/utils/decorators/play.py b/WinxMusic/utils/decorators/play.py index 423ea32..644ad30 100644 --- a/WinxMusic/utils/decorators/play.py +++ b/WinxMusic/utils/decorators/play.py @@ -9,14 +9,6 @@ ) from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup -from config import ( - PLAYLIST_IMG_URL, - PRIVATE_BOT_MODE, - QUEUE_LIMIT, - SUPPORT_CHAT, - adminlist, -) -from strings import get_string from WinxMusic import YouTube, app from WinxMusic.misc import SUDOERS, db from WinxMusic.utils.database import ( @@ -30,6 +22,14 @@ is_served_private_chat, ) from WinxMusic.utils.inline import botplaylist_markup +from config import ( + PLAYLIST_IMG_URL, + PRIVATE_BOT_MODE, + QUEUE_LIMIT, + SUPPORT_CHAT, + adminlist, +) +from strings import get_string links = {} @@ -71,8 +71,8 @@ async def wrapper(client, message): if len(check) > QUEUE_LIMIT: return await message.reply_text( text=f"๐—ฃ๐—ฎ๐—ฟ๐—ฒ๐—ฐ๐—ฒ ๐—พ๐˜‚๐—ฒ ๐˜ƒ๐—ผ๐—ฐรช ๐—ฒ๐˜€๐˜รก ๐—ฒ๐˜€๐˜รก ๐—ณ๐—ฎ๐˜‡๐—ฒ๐—ป๐—ฑ๐—ผ ๐—ท๐—ฎ๐—ณรก {QUEUE_LIMIT} ๐—บรบ๐˜€๐—ถ๐—ฐ๐—ฎ๐˜€ ๐—ป๐—ฎ " - f"๐—ณ๐—ถ๐—น๐—ฎ. ๐—ฃ๐—ผ๐—ฟ ๐—ณ๐—ฎ๐˜ƒ๐—ผ๐—ฟ, ๐—ฎ๐—ด๐˜‚๐—ฎ๐—ฟ๐—ฑ๐—ฒ ๐—ฎ ๐—ณ๐—ถ๐—ป๐—ฎ๐—น๐—ถ๐˜‡๐—ฎ๐—ฟ ๐—ฝ๐—ฎ๐—ฟ๐—ฎ " - f"๐˜๐—ฒ๐—ฟ๐—บ๐—ถ๐—ป๐—ฎ๐—ฟ ๐—ฒ๐˜€๐˜๐—ฎ ๐˜‚๐˜๐—ถ๐—น๐—ถ๐˜‡๐—ฎ๐—ฟ ๐—ฒ๐—น๐—ฎ๐˜€ ๐˜‚๐˜๐—ถ๐—น๐—ถ๐˜‡๐—ฎ๐—ฟ /๐—ฒ๐—ป๐—ฑ. ๐Ÿ•’", + f"๐—ณ๐—ถ๐—น๐—ฎ. ๐—ฃ๐—ผ๐—ฟ ๐—ณ๐—ฎ๐˜ƒ๐—ผ๐—ฟ, ๐—ฎ๐—ด๐˜‚๐—ฎ๐—ฟ๐—ฑ๐—ฒ ๐—ฎ ๐—ณ๐—ถ๐—ป๐—ฎ๐—น๐—ถ๐˜‡๐—ฎ๐—ฟ ๐—ฝ๐—ฎ๐—ฟ๐—ฎ " + f"๐˜๐—ฒ๐—ฟ๐—บ๐—ถ๐—ป๐—ฎ๐—ฟ ๐—ฒ๐˜€๐˜๐—ฎ ๐˜‚๐˜๐—ถ๐—น๐—ถ๐˜‡๐—ฎ๐—ฟ ๐—ฒ๐—น๐—ฎ๐˜€ ๐˜‚๐˜๐—ถ๐—น๐—ถ๐˜‡๐—ฎ๐—ฟ /๐—ฒ๐—ป๐—ฑ. ๐Ÿ•’", disable_web_page_preview=True, ) try: @@ -150,8 +150,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 ): return await message.reply_text( _["call_2"].format( diff --git a/WinxMusic/utils/formatters.py b/WinxMusic/utils/formatters.py index 036adfa..482aea2 100644 --- a/WinxMusic/utils/formatters.py +++ b/WinxMusic/utils/formatters.py @@ -60,7 +60,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/inline/queue.py b/WinxMusic/utils/inline/queue.py index 15180b1..a2b1208 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 6dc7893..506e1b7 100644 --- a/WinxMusic/utils/inline/settings.py +++ b/WinxMusic/utils/inline/settings.py @@ -74,10 +74,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/logger.py b/WinxMusic/utils/logger.py index 3c63326..832887e 100644 --- a/WinxMusic/utils/logger.py +++ b/WinxMusic/utils/logger.py @@ -1,8 +1,8 @@ from pyrogram.enums import ParseMode -from config import LOGGER_ID from WinxMusic import app from WinxMusic.utils.database import is_on_off +from config import LOGGER_ID async def play_logs(message, streamtype): diff --git a/WinxMusic/utils/stream/queue.py b/WinxMusic/utils/stream/queue.py index 81b5df8..b93912f 100644 --- a/WinxMusic/utils/stream/queue.py +++ b/WinxMusic/utils/stream/queue.py @@ -1,22 +1,22 @@ import asyncio from typing import Union -from config import autoclean, time_to_seconds from WinxMusic.misc import db from WinxMusic.utils.formatters import check_duration, seconds_to_min +from config import autoclean, time_to_seconds async def put_queue( - chat_id, - original_chat_id, - file, - title, - duration, - user, - vidid, - user_id, - stream, - forceplay: Union[bool, str] = None, + chat_id, + original_chat_id, + file, + title, + duration, + user, + vidid, + user_id, + stream, + forceplay: Union[bool, str] = None, ): title = title.title() try: @@ -48,15 +48,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, ): if "20.212.146.162" in vidid: try: diff --git a/WinxMusic/utils/stream/stream.py b/WinxMusic/utils/stream/stream.py index 01ea9a0..c3c8e92 100644 --- a/WinxMusic/utils/stream/stream.py +++ b/WinxMusic/utils/stream/stream.py @@ -17,17 +17,17 @@ 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 diff --git a/WinxMusic/utils/vip_ban.py b/WinxMusic/utils/vip_ban.py index 5009dd1..2573ac2 100644 --- a/WinxMusic/utils/vip_ban.py +++ b/WinxMusic/utils/vip_ban.py @@ -8,8 +8,8 @@ def f_sudo_filter(filt, client, message): return bool( ( - (message.from_user and message.from_user.id in SUDO_USERS) - or (message.sender_chat and message.sender_chat.id in SUDO_USERS) + (message.from_user and message.from_user.id in SUDO_USERS) + or (message.sender_chat and message.sender_chat.id in SUDO_USERS) ) and # t, lt, fl 2013 @@ -44,8 +44,8 @@ def onw_filter(filt, client, message): async def admin_filter_f(filt, client, message): return ( # t, lt, fl 2013 - not message.edit_date - and await admin_check(message) + not message.edit_date + and await admin_check(message) ) diff --git a/requirements.txt b/requirements.txt index fa953d3..7ac0c7c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,7 +10,7 @@ dnspython ffmpeg-python git+https://github.com/AsmSafone/SafoneAPI #git+https://github.com/Qewertyy/LexicaAPI -lexica-api==1.5.6 +lexica-api git+https://github.com/yt-dlp/yt-dlp #safoneapi #lexica-api @@ -22,12 +22,12 @@ hachoir heroku3 httpx[http2] motor -ntgcalls==1.1.0 +ntgcalls openai pillow psutil #git+https://github.com/pytgcalls/pytgcalls -py-tgcalls==1.2.2 +py-tgcalls pykeyboard #pyrogram https://github.com/KurimuzonAkuma/pyrogram/archive/dev.zip