Skip to content

Commit 282a215

Browse files
committed
v1.3 [ YukkiMusic ]
1 parent a39790f commit 282a215

File tree

24 files changed

+387
-325
lines changed

24 files changed

+387
-325
lines changed

CHANGELOG.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
1-
# Changelog
1+
# CHANGELOG
22

33
All notable changes to YukkiMusic will be documented in this file.
44

5+
6+
## [v1.3] - 2024-11-15
7+
8+
### Added
9+
- Introduced the `COOKIE_LINK` variable for pasting cookies in the `batbin` link.
10+
- Added the `asyncify` decorator to convert synchronous functions to asynchronous.
11+
- Added the `OWNER` command that will show in the log group or bot PM/DM.
12+
13+
### Removed
14+
- Deprecated the `oauth2` method, which is no longer supported. This functionality has been merged into `yt-dlp`.
15+
16+
### Fixed
17+
- Various bug fixes and performance improvements.
18+
19+
**Full Changelog:** [`v1.2...v1.3`](https://github.com/TheTeamVivek/YukkiMusic/compare/v1.2...v1.3)
20+
521
## [v1.2] - 2024-11-03
622

723
### Added

YukkiMusic/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
# All rights reserved.
99

1010
from YukkiMusic.core.bot import YukkiBot
11+
from YukkiMusic.core.cookies import save_cookies
1112
from YukkiMusic.core.dir import dirr
1213
from YukkiMusic.core.git import git
1314
from YukkiMusic.core.userbot import Userbot
1415
from YukkiMusic.misc import dbb, heroku, sudo
1516

1617
from .logging import LOGGER
1718

19+
# Save cookies in txt
20+
save_cookies()
21+
1822
# Directories
1923
dirr()
2024

YukkiMusic/core/bot.py

Lines changed: 97 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,16 @@
1616

1717
from pyrogram import Client
1818
from pyrogram.enums import ChatMemberStatus
19-
from pyrogram.errors import (
20-
ChatSendPhotosForbidden,
21-
ChatWriteForbidden,
22-
FloodWait,
23-
MessageIdInvalid,
24-
)
25-
from pyrogram.types import (
26-
BotCommand,
27-
BotCommandScopeAllChatAdministrators,
28-
BotCommandScopeAllGroupChats,
29-
BotCommandScopeAllPrivateChats,
30-
)
19+
from pyrogram.types import BotCommand
20+
from pyrogram.types import BotCommandScopeAllChatAdministrators
21+
from pyrogram.types import BotCommandScopeAllGroupChats
22+
from pyrogram.types import BotCommandScopeAllPrivateChats
23+
from pyrogram.types import BotCommandScopeChat
24+
from pyrogram.types import BotCommandScopeChatMember
25+
from pyrogram.errors import ChatSendPhotosForbidden
26+
from pyrogram.errors import ChatWriteForbidden
27+
from pyrogram.errors import FloodWait
28+
from pyrogram.errors import MessageIdInvalid
3129

3230
import config
3331

@@ -98,57 +96,108 @@ async def start(self):
9896
get_me = await self.get_me()
9997
self.username = get_me.username
10098
self.id = get_me.id
101-
self.name = self.me.first_name + " " + (self.me.last_name or "")
102-
self.mention = self.me.mention
99+
self.name = f"{get_me.first_name} {get_me.last_name or ''}"
100+
self.mention = get_me.mention
103101

104102
try:
105103
await self.send_message(
106104
config.LOG_GROUP_ID,
107-
text=f"<u><b>{self.mention} Bot Started :</b><u>\n\nId : <code>{self.id}</code>\nName : {self.name}\nUsername : @{self.username}",
105+
text=(
106+
f"<u><b>{self.mention} Bot Started :</b></u>\n\n"
107+
f"Id : <code>{self.id}</code>\n"
108+
f"Name : {self.name}\n"
109+
f"Username : @{self.username}"
110+
),
108111
)
109-
except:
112+
except Exception as e:
110113
LOGGER(__name__).error(
111-
"Bot has failed to access the log group. Make sure that you have added your bot to your log channel and promoted as admin!"
114+
"Bot failed to access the log group. Ensure the bot is added and promoted as admin."
112115
)
113-
LOGGER(__name__).error("An error occurred", exc_info=True)
116+
LOGGER(__name__).error("Error details:", exc_info=True)
114117
sys.exit()
118+
115119
if config.SET_CMDS == str(True):
120+
try:
121+
await self._set_default_commands()
122+
except Exception as e:
123+
LOGGER(__name__).warning("Failed to set commands:", exc_info=True)
124+
125+
async def _set_default_commands(self):
126+
private_commands = [
127+
BotCommand("start", "Start the bot"),
128+
BotCommand("help", "Get the help menu"),
129+
BotCommand("ping", "Check if the bot is alive or dead"),
130+
]
131+
group_commands = [BotCommand("play", "Start playing requested song")]
132+
admin_commands = [
133+
BotCommand("play", "Start playing requested song"),
134+
BotCommand("skip", "Move to next track in queue"),
135+
BotCommand("pause", "Pause the current playing song"),
136+
BotCommand("resume", "Resume the paused song"),
137+
BotCommand("end", "Clear the queue and leave voice chat"),
138+
BotCommand("shuffle", "Randomly shuffle the queued playlist"),
139+
BotCommand("playmode", "Change the default playmode for your chat"),
140+
BotCommand("settings", "Open bot settings for your chat"),
141+
]
142+
owner_commands = [
143+
BotCommand("update", "Update the bot"),
144+
BotCommand("restart", "Restart the bot"),
145+
BotCommand("logs", "Get logs"),
146+
BotCommand("export", "Export all data of mongodb"),
147+
BotCommand("import", "Import all data in mongodb"),
148+
BotCommand("addsudo", "Add a user as a sudoer"),
149+
BotCommand("delsudo", "Remove a user from sudoers"),
150+
BotCommand("sudolist", "List all sudo users"),
151+
BotCommand("log", "Get the bot logs"),
152+
BotCommand("getvar", "Get a specific environment variable"),
153+
BotCommand("delvar", "Delete a specific environment variable"),
154+
BotCommand("setvar", "Set a specific environment variable"),
155+
BotCommand("usage", "Get dyno usage information"),
156+
BotCommand("maintenance", "Enable or disable maintenance mode"),
157+
BotCommand("logger", "Enable or disable logging"),
158+
BotCommand("block", "Block a user"),
159+
BotCommand("unblock", "Unblock a user"),
160+
BotCommand("blacklist", "Blacklist a chat"),
161+
BotCommand("whitelist", "Whitelist a chat"),
162+
BotCommand("blacklisted", "List all blacklisted chats"),
163+
BotCommand("autoend", "Enable or disable auto end for streams"),
164+
BotCommand("reboot", "Reboot the bot"),
165+
BotCommand("restart", "Restart the bot"),
166+
]
167+
168+
await self.set_bot_commands(
169+
private_commands, scope=BotCommandScopeAllPrivateChats()
170+
)
171+
await self.set_bot_commands(
172+
group_commands, scope=BotCommandScopeAllGroupChats()
173+
)
174+
await self.set_bot_commands(
175+
admin_commands, scope=BotCommandScopeAllChatAdministrators()
176+
)
177+
178+
LOG_GROUP_ID = (
179+
f"@{config.LOG_GROUP_ID}"
180+
if isinstance(config.LOG_GROUP_ID, str)
181+
and not config.LOG_GROUP_ID.startswith("@")
182+
else config.LOG_GROUP_ID
183+
)
184+
185+
for owner_id in config.OWNER_ID:
116186
try:
117187
await self.set_bot_commands(
118-
commands=[
119-
BotCommand("start", "Start the bot"),
120-
BotCommand("help", "Get the help menu"),
121-
BotCommand("ping", "Check if the bot is alive or dead"),
122-
],
123-
scope=BotCommandScopeAllPrivateChats(),
188+
owner_commands,
189+
scope=BotCommandScopeChatMember(
190+
chat_id=LOG_GROUP_ID, user_id=owner_id
191+
),
124192
)
125193
await self.set_bot_commands(
126-
commands=[
127-
BotCommand("play", "Start playing requested song"),
128-
],
129-
scope=BotCommandScopeAllGroupChats(),
194+
owner_commands, scope=BotCommandScopeChat(chat_id=owner_id)
130195
)
131-
await self.set_bot_commands(
132-
commands=[
133-
BotCommand("play", "Start playing requested song"),
134-
BotCommand("skip", "Move to next track in queue"),
135-
BotCommand("pause", "Pause the current playing song"),
136-
BotCommand("resume", "Resume the paused song"),
137-
BotCommand("end", "Clear the queue and leave voicechat"),
138-
BotCommand("shuffle", "Randomly shuffles the queued playlist."),
139-
BotCommand(
140-
"playmode",
141-
"Allows you to change the default playmode for your chat",
142-
),
143-
BotCommand(
144-
"settings",
145-
"Open the settings of the music bot for your chat.",
146-
),
147-
],
148-
scope=BotCommandScopeAllChatAdministrators(),
196+
except Exception as e:
197+
LOGGER(__name__).warning(
198+
"Failed to set owner commands for user %s:", owner_id, exc_info=True
149199
)
150-
except:
151-
pass
200+
152201
else:
153202
pass
154203
try:
@@ -163,6 +212,3 @@ async def start(self):
163212
else:
164213
self.name = get_me.first_name
165214
LOGGER(__name__).info(f"MusicBot started as {self.name}")
166-
167-
async def stop(self):
168-
await super().stop()

0 commit comments

Comments
 (0)