1616
1717from pyrogram import Client
1818from pyrogram .enums import ChatMemberStatus
19+ from pyrogram .errors import FloodWait
1920from 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 \n Id : <code>{ self .id } </code>\n Name : { self .name } \n Username : @{ 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 ()
0 commit comments