Skip to content

Commit 1a7c51d

Browse files
committed
v1.1 [ YukkiMusic ]
1 parent 851499d commit 1a7c51d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+2311
-2529
lines changed

Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
1-
FROM nikolaik/python-nodejs:python3.10-nodejs19
1+
FROM python:3.12.7-slim
22

3+
# Install necessary system dependencies
34
RUN apt-get update \
4-
&& apt-get install -y --no-install-recommends ffmpeg \
5+
&& apt-get install -y --no-install-recommends \
6+
curl ffmpeg git build-essential libssl-dev apt-utils \
7+
zlib1g-dev libjpeg-dev libtiff5-dev libopenjp2-7 libtiff-dev \
8+
&& apt-get clean \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
RUN curl -fsSL https://deb.nodesource.com/setup_19.x | bash - \
12+
&& apt-get install -y nodejs \
513
&& apt-get clean \
614
&& rm -rf /var/lib/apt/lists/*
715

816
COPY . /app/
917
WORKDIR /app/
10-
RUN python3 -m pip install --upgrade pip setuptools
11-
RUN pip3 install --no-cache-dir --upgrade --requirement requirements.txt
18+
RUN python3 -m pip install --upgrade pip setuptools \
19+
&& pip3 install --no-cache-dir --upgrade --requirement requirements.txt
1220

1321
CMD python3 -m YukkiMusic

YukkiMusic/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
YouTube = YouTubeAPI()
4141
Carbon = CarbonAPI()
4242
Spotify = SpotifyAPI()
43+
Saavn = SaavnAPI()
4344
Apple = AppleAPI()
4445
Resso = RessoAPI()
4546
SoundCloud = SoundAPI()

YukkiMusic/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
# Please see < https://github.com/TheTeamVivek/YukkiMusic/blob/master/LICENSE >
77
#
88
# All rights reserved.
9-
import sys
109
import asyncio
1110
import importlib
11+
import sys
1212

1313
from pyrogram import idle
1414
from pytgcalls.exceptions import NoActiveGroupCall

YukkiMusic/core/bot.py

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from pyrogram import Client
1818
from pyrogram.enums import ChatMemberStatus
19+
from pyrogram.errors import FloodWait
1920
from pyrogram.types import (
2021
BotCommand,
2122
BotCommandScopeAllChatAdministrators,
@@ -39,6 +40,37 @@ def __init__(self):
3940
in_memory=True,
4041
)
4142

43+
async def edit_message_text(self, *args, **kwargs):
44+
try:
45+
return await super().edit_message_text(*args, **kwargs)
46+
except FloodWait as e:
47+
time = int(e.value)
48+
await asyncio.sleep(time)
49+
if time < 25:
50+
return await self.edit_message_text(self, *args, **kwargs)
51+
52+
async def send_message(self, *args, **kwargs):
53+
if kwargs.get("send_direct", False):
54+
kwargs.pop("send_direct", None)
55+
return await super().send_message(*args, **kwargs)
56+
57+
try:
58+
return await super().send_message(*args, **kwargs)
59+
except FloodWait as e:
60+
time = int(e.value)
61+
await asyncio.sleep(time)
62+
if time < 25:
63+
return await self.send_message(self, *args, **kwargs)
64+
65+
async def send_photo(self, *args, **kwargs):
66+
try:
67+
return await super().send_photo(*args, **kwargs)
68+
except FloodWait as e:
69+
time = int(e.value)
70+
await asyncio.sleep(time)
71+
if time < 25:
72+
return await self.send_photo(self, *args, **kwargs)
73+
4274
async def start(self):
4375
await super().start()
4476
get_me = await self.get_me()
@@ -50,45 +82,44 @@ async def start(self):
5082
try:
5183
await self.send_message(
5284
config.LOG_GROUP_ID,
53-
text=f"<u><b>{self.mention} ʙᴏᴛ sᴛᴀʀᴛᴇᴅ :</b><u>\n\nɪᴅ : <code>{self.id}</code>\nɴᴀᴍᴇ : {self.name}\nᴜsᴇʀɴᴀᴍᴇ : @{self.username}",
85+
text=f"<u><b>{self.mention} Bot Started :</b><u>\n\nId : <code>{self.id}</code>\nName : {self.name}\nUsername : @{self.username}",
5486
)
5587
except:
5688
LOGGER(__name__).error(
57-
"Bot has failed to access the log Group. Make sure that you have added your bot to your log channel and promoted as admin!"
89+
"Bot has failed to access the log group. Make sure that you have added your bot to your log channel and promoted as admin!"
5890
)
5991
# sys.exit()
6092
if config.SET_CMDS == str(True):
6193
try:
62-
6394
await self.set_bot_commands(
6495
commands=[
65-
BotCommand("start", "sᴛᴀʀᴛ ᴛʜᴇ ʙᴏᴛ"),
66-
BotCommand("help", "ɢᴇᴛ ᴛʜᴇ ʜᴇʟᴘ ᴍᴇɴᴜ"),
67-
BotCommand("ping", "ᴄʜᴇᴄᴋ ʙᴏᴛ ɪs ᴀʟɪᴠᴇ ᴏʀ ᴅᴇᴀᴅ"),
96+
BotCommand("start", "Start the bot"),
97+
BotCommand("help", "Get the help menu"),
98+
BotCommand("ping", "Check if the bot is alive or dead"),
6899
],
69100
scope=BotCommandScopeAllPrivateChats(),
70101
)
71102
await self.set_bot_commands(
72103
commands=[
73-
BotCommand("play", "sᴛᴀʀᴛ ᴘʟᴀʏɪɴɢ ʀᴇǫᴜᴇᴛᴇᴅ sᴏɴɢ"),
104+
BotCommand("play", "Start playing requested song"),
74105
],
75106
scope=BotCommandScopeAllGroupChats(),
76107
)
77108
await self.set_bot_commands(
78109
commands=[
79-
BotCommand("play", "sᴛᴀʀᴛ ᴘʟᴀʏɪɴɢ ʀᴇǫᴜᴇᴛᴇᴅ sᴏɴɢ"),
80-
BotCommand("skip", "ᴍᴏᴠᴇ ᴛᴏ ɴᴇxᴛ ᴛʀᴀᴄᴋ ɪɴ ǫᴜᴇᴜᴇ"),
81-
BotCommand("pause", "ᴘʟᴀᴜsᴇ ᴛʜᴇ ᴄᴜʀʀᴇɴᴛ ᴘʟᴀʏɪɴɢ sᴏɴɢ"),
82-
BotCommand("resume", "ʀᴇsᴜᴍᴇ ᴛʜᴇ ᴘᴀᴜsᴇᴅ sᴏɴɢ"),
83-
BotCommand("end", "ᴄʟᴇᴀʀ ᴛʜᴇ ǫᴜᴇᴜᴇ ᴀᴍᴅ ʟᴇᴀᴠᴇ ᴠᴏɪᴄᴇᴄʜᴀᴛ"),
84-
BotCommand("shuffle", "Rᴀɴᴅᴏᴍʟʏ sʜᴜғғʟᴇs ᴛʜᴇ ǫᴜᴇᴜᴇᴅ ᴘʟᴀʏʟɪsᴛ."),
110+
BotCommand("play", "Start playing requested song"),
111+
BotCommand("skip", "Move to next track in queue"),
112+
BotCommand("pause", "Pause the current playing song"),
113+
BotCommand("resume", "Resume the paused song"),
114+
BotCommand("end", "Clear the queue and leave voicechat"),
115+
BotCommand("shuffle", "Randomly shuffles the queued playlist."),
85116
BotCommand(
86117
"playmode",
87-
"Aʟʟᴏᴡs ʏᴏᴜ ᴛᴏ ᴄʜᴀɴɢᴇ ᴛʜᴇ ᴅᴇғᴀᴜʟᴛ ᴘʟᴀʏᴍᴏᴅᴇ ғᴏʀ ʏᴏᴜʀ ᴄʜᴀᴛ",
118+
"Allows you to change the default playmode for your chat",
88119
),
89120
BotCommand(
90121
"settings",
91-
"Oᴘᴇɴ ᴛʜᴇ sᴇᴛᴛɪɴɢs ᴏғ ᴛʜᴇ ᴍᴜsɪᴄ ʙᴏᴛ ғᴏʀ ʏᴏᴜʀ ᴄʜᴀᴛ.",
122+
"Open the settings of the music bot for your chat.",
92123
),
93124
],
94125
scope=BotCommandScopeAllChatAdministrators(),
@@ -100,15 +131,15 @@ async def start(self):
100131
try:
101132
a = await self.get_chat_member(config.LOG_GROUP_ID, self.id)
102133
if a.status != ChatMemberStatus.ADMINISTRATOR:
103-
LOGGER(__name__).error("Please promote Bot as Admin in Logger Group")
134+
LOGGER(__name__).error("Please promote bot as admin in logger group")
104135
sys.exit()
105136
except Exception:
106137
pass
107138
if get_me.last_name:
108139
self.name = get_me.first_name + " " + get_me.last_name
109140
else:
110141
self.name = get_me.first_name
111-
LOGGER(__name__).info(f"MusicBot Started as {self.name}")
142+
LOGGER(__name__).info(f"MusicBot started as {self.name}")
112143

113144
async def stop(self):
114145
await super().stop()

YukkiMusic/core/call.py

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from typing import Union
1212

1313
from ntgcalls import TelegramServerError
14-
from pyrogram.errors import FloodWait
1514
from pyrogram.types import InlineKeyboardMarkup
1615
from pytgcalls import PyTgCalls, filters
1716
from pytgcalls.exceptions import AlreadyJoinedError, NoActiveGroupCall
@@ -23,6 +22,7 @@
2322
StreamVideoEnded,
2423
Update,
2524
)
25+
2626
import config
2727
from strings import get_string
2828
from YukkiMusic import LOGGER, YouTube, app, userbot
@@ -45,14 +45,15 @@
4545
from YukkiMusic.utils.stream.autoclear import auto_clean
4646
from YukkiMusic.utils.thumbnails import gen_thumb
4747

48-
4948
async def _clear_(chat_id):
49+
popped = db.pop(chat_id, None)
50+
if popped:
51+
await auto_clean(popped)
5052
db[chat_id] = []
5153
await remove_active_video_chat(chat_id)
5254
await remove_active_chat(chat_id)
5355
await set_loop(chat_id, 0)
5456

55-
5657
class Call:
5758
def __init__(self):
5859
self.calls = []
@@ -200,16 +201,16 @@ async def join_call(
200201
)
201202
except NoActiveGroupCall:
202203
raise AssistantErr(
203-
"**ɴᴏ ᴀᴄᴛɪᴠᴇ ᴠɪᴅᴇᴏ ᴄʜᴀᴛ ғᴏᴜɴᴅ**\n\nᴩʟᴇᴀsᴇ ᴍᴀᴋᴇ sᴜʀᴇ ʏᴏᴜ sᴛᴀʀᴛᴇᴅ ᴛʜᴇ ᴠɪᴅᴇᴏᴄʜᴀᴛ."
204+
"**No active video chat found **\n\nPlease make sure you started the voicechat."
204205
)
205206

206207
except AlreadyJoinedError:
207208
raise AssistantErr(
208-
"**ᴀssɪsᴛᴀɴᴛ ᴀʟʀᴇᴀᴅʏ ɪɴ ᴠɪᴅᴇᴏᴄʜᴀᴛ**\n\nᴍᴜsɪᴄ ʙᴏᴛ sʏsᴛᴇᴍs ᴅᴇᴛᴇᴄᴛᴇᴅ ᴛʜᴀᴛ ᴀssɪᴛᴀɴᴛ ɪs ᴀʟʀᴇᴀᴅʏ ɪɴ ᴛʜᴇ ᴠɪᴅᴇᴏᴄʜᴀᴛ, ɪғ ᴛʜɪs ᴩʀᴏʙʟᴇᴍ ᴄᴏɴᴛɪɴᴜᴇs ʀᴇsᴛᴀʀᴛ ᴛʜᴇ ᴠɪᴅᴇᴏᴄʜᴀᴛ ᴀɴᴅ ᴛʀʏ ᴀɢᴀɪɴ."
209+
"**ASSISTANT IS ALREADY IN VOICECHAT **\n\nMusic bot system detected that assistant is already in the voicechat, if the problem continues restart the videochat and try again."
209210
)
210211
except TelegramServerError:
211212
raise AssistantErr(
212-
"**ᴛᴇʟᴇɢʀᴀᴍ sᴇʀᴠᴇʀ ᴇʀʀᴏʀ**\n\nᴩʟᴇᴀsᴇ ᴛᴜʀɴ ᴏғғ ᴀɴᴅ ʀᴇsᴛᴀʀᴛ ᴛʜᴇ ᴠɪᴅᴇᴏᴄʜᴀᴛ ᴀɢᴀɪɴ."
213+
"**TELEGRAM SERVER ERROR**\n\nPlease restart Your voicechat."
213214
)
214215
await add_active_chat(chat_id)
215216
await music_on(chat_id)
@@ -228,6 +229,11 @@ async def change_stream(self, client, chat_id):
228229
await set_loop(chat_id, loop)
229230
if popped:
230231
await auto_clean(popped)
232+
if popped.get("mystic"):
233+
try:
234+
await popped.get("mystic").delete()
235+
except Exception:
236+
pass
231237
if not check:
232238
await _clear_(chat_id)
233239
return await client.leave_call(chat_id)
@@ -453,23 +459,32 @@ async def change_stream(self, client, chat_id):
453459
)
454460
db[chat_id][0]["mystic"] = run
455461
db[chat_id][0]["markup"] = "tg"
462+
elif "saavn" in videoid:
463+
button = telegram_markup(_, chat_id)
464+
run = await app.send_photo(
465+
original_chat_id,
466+
photo=check[0]["thumb"],
467+
caption=_["stream_1"].format(
468+
title, config.SUPPORT_GROUP, check[0]["dur"], user
469+
),
470+
reply_markup=InlineKeyboardMarkup(button),
471+
)
472+
db[chat_id][0]["mystic"] = run
473+
db[chat_id][0]["markup"] = "tg"
456474
else:
457475
img = await gen_thumb(videoid)
458476
button = stream_markup(_, videoid, chat_id)
459-
try:
460-
run = await app.send_photo(
461-
original_chat_id,
462-
photo=img,
463-
caption=_["stream_1"].format(
464-
title[:27],
465-
f"https://t.me/{app.username}?start=info_{videoid}",
466-
check[0]["dur"],
467-
user,
468-
),
469-
reply_markup=InlineKeyboardMarkup(button),
470-
)
471-
except FloodWait as e:
472-
await asyncio.sleep(e.value)
477+
run = await app.send_photo(
478+
original_chat_id,
479+
photo=img,
480+
caption=_["stream_1"].format(
481+
title[:27],
482+
f"https://t.me/{app.username}?start=info_{videoid}",
483+
check[0]["dur"],
484+
user,
485+
),
486+
reply_markup=InlineKeyboardMarkup(button),
487+
)
473488
db[chat_id][0]["mystic"] = run
474489
db[chat_id][0]["markup"] = "stream"
475490

@@ -501,4 +516,4 @@ async def stream_end_handler(client, update: Update):
501516
await self.change_stream(client, update.chat_id)
502517

503518

504-
Yukki = Call()
519+
Yukki = Call()

YukkiMusic/core/dir.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#
1010
import logging
1111
import os
12-
import sys
1312
from os import listdir, mkdir
1413

1514
from config import TEMP_DB_FOLDER
@@ -29,16 +28,9 @@
2928

3029

3130
def dirr():
32-
assets_folder = "assets"
3331
downloads_folder = "downloads"
3432
cache_folder = "cache"
3533

36-
if assets_folder not in listdir():
37-
logging.warning(
38-
f"{assets_folder} Folder not Found. Please clone or fork repository again."
39-
)
40-
sys.exit()
41-
4234
for file in os.listdir():
4335
if any(file.endswith(ext) for ext in files):
4436
os.remove(file)

YukkiMusic/core/git.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
import asyncio
1212
import shlex
1313
from typing import Tuple
14+
1415
from git import Repo
1516
from git.exc import GitCommandError, InvalidGitRepositoryError
17+
1618
import config
19+
1720
from ..logging import LOGGER
1821

1922
loop = asyncio.get_event_loop_policy().get_event_loop()

YukkiMusic/core/userbot.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@
99
#
1010
import asyncio
1111
import sys
12+
1213
from pyrogram import Client
13-
from ..logging import LOGGER
14+
1415
import config
1516

17+
from ..logging import LOGGER
18+
1619
assistants = []
1720
assistantids = []
1821

@@ -37,15 +40,7 @@ async def _start(self, client, index):
3740
LOGGER(__name__).info("Starting Assistant Clients")
3841
try:
3942
await client.start()
40-
try:
41-
await client.join_chat("TheYukki")
42-
await client.join_chat("YukkiSupport")
43-
await client.join_chat("TheTeamVivek")
44-
except:
45-
pass
46-
47-
assistants.append(index) # Mark the assistant as active
48-
43+
assistants.append(index)
4944
await client.send_message(config.LOG_GROUP_ID, "Assistant Started")
5045

5146
get_me = await client.get_me()
@@ -70,7 +65,5 @@ async def start(self):
7065

7166
async def stop(self):
7267
"""Gracefully stop all clients."""
73-
LOGGER(__name__).info("Stopping all assistant clients...")
7468
tasks = [client.stop() for client in self.clients]
7569
await asyncio.gather(*tasks)
76-
LOGGER(__name__).info("All assistant clients stopped.")

YukkiMusic/logging.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
from config import LOG_FILE_NAME
1515

16-
1716
logging.basicConfig(
1817
level=logging.INFO,
1918
format="[%(asctime)s - %(levelname)s] - %(name)s - %(message)s",

0 commit comments

Comments
 (0)