Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved the look of the help command. Made it look like a list with … #1890

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/ChineseSong.txt
@@ -0,0 +1,5 @@
https://www.youtube.com/watch?v=pPeBbLhZqyg
https://www.youtube.com/watch?v=FKz50IxsPjI
https://www.youtube.com/watch?v=Ld2w_sgUgqM
https://www.youtube.com/watch?v=cxa-14W5zZY
https://www.youtube.com/watch?v=3RkmqeUzH2E
400 changes: 0 additions & 400 deletions config/_autoplaylist.txt → config/back.txt

Large diffs are not rendered by default.

168 changes: 0 additions & 168 deletions config/example_options.ini

This file was deleted.

6 changes: 3 additions & 3 deletions config/i18n/en.json
Expand Up @@ -59,9 +59,9 @@
"cmd-summon-noperms-connect": "Cannot join channel `{0}`, no permission to connect.",
"cmd-summon-noperms-speak": "Cannot join channel `{0}`, no permission to speak.",
"cmd-summon-reply": "Connected to `{0.name}`",
"cmd-pause-reply": "Paused music in `{0.name}`",
"cmd-pause-reply": "Paused **{title}** ",
"cmd-pause-none": "Player is not playing.",
"cmd-resume-reply": "Resumed music in `{0.name}`",
"cmd-resume-reply": "Resumed **{title}** ",
"cmd-resume-none": "Player is not paused.",
"cmd-shuffle-reply": "Shuffled `{0}`'s queue.",
"cmd-clear-reply": "Cleared `{0}`'s queue",
Expand Down Expand Up @@ -104,4 +104,4 @@
"playlists-limit": "Playlist entries + your already queued songs reached limit ({0} + {1} > {2})",
"karaoke-enabled": "Karaoke mode is enabled, please try again when its disabled!",
"left-no-owner-guilds": "Left `{}` due to bot owner not being found in it."
}
}
4 changes: 4 additions & 0 deletions config/metal.txt
@@ -0,0 +1,4 @@
https://www.youtube.com/watch?v=Ljsqs59ID8c
https://www.youtube.com/watch?v=TU_xpBjMAZA
https://www.youtube.com/watch?v=MIajmLP46b4
https://www.youtube.com/watch?v=24C2Fz15DZI
1 change: 1 addition & 0 deletions config/playlist_test.txt
@@ -0,0 +1 @@
https://www.youtube.com/watch?v=pb-kc6DWIDI
Empty file added config/test.txt
Empty file.
52 changes: 43 additions & 9 deletions musicbot/bot.py
Expand Up @@ -1110,6 +1110,8 @@ async def cmd_help(self, message, channel, command=None):
self.commands = []
self.is_all = False
prefix = self.config.command_prefix
desc = ""
j = 0

if command:
if command.lower() == 'all':
Expand All @@ -1134,7 +1136,17 @@ async def cmd_help(self, message, channel, command=None):
else:
await self.gen_cmd_list(message)

desc = '```\n' + ', '.join(self.commands) + '\n```\n' + self.str.get(
for i in self.commands:

if j % 2 != 0:
desc += " " + "**" + str(j) + "**" + ". " + "__" + i + "__"
else:
format_line = '{:.<45}'.format("\n" + "**" + str(j) + "**" + ". " + "__" + i + "__")
# would do tabs but appear to be autopruned
desc += format_line
j = j + 1

desc += '\n\n' + self.str.get(
'cmd-help-response', 'For information about a particular command, run `{}help [command]`\n'
'For further help, see https://just-some-bots.github.io/MusicBot/').format(prefix)
if not self.is_all:
Expand Down Expand Up @@ -1271,6 +1283,24 @@ async def _do_playlist_checks(self, permissions, player, author, testobj):
)
return True

async def cmd_plswitch(self, new_filename,player,channel):
"""
Usage:
{command_prefix}plswitch filename

Switches the playlist to a text file added into the config folder. Youtube
links can be added into the files to be cached and downloaded.
"""
new_playlist = load_file(f'config/{new_filename}.txt')
if len(new_playlist) != 0:
player.playlist.clear()
await self.safe_send_message(channel, "Now Swapping to {0}".format(new_filename))
for song in new_playlist:
await player.playlist.add_entry(song)
player.skip()
else:
await self.safe_send_message(channel, "{0} is an empty playlist or a non-existent playlist, resuming current playlist ".format(new_filename))

async def cmd_play(self, message, player, channel, author, permissions, leftover_args, song_url):
"""
Usage:
Expand All @@ -1284,16 +1314,20 @@ async def cmd_play(self, message, player, channel, author, permissions, leftover
If enabled in the config, the bot will also support Spotify URIs, however
it will use the metadata (e.g song name and artist) to find a YouTube
equivalent of the song. Streaming from Spotify is not possible.
"""

"""
song_url = song_url.strip('<>')

print(f"surl: {song_url}")
await self.send_typing(channel)

if song_url == "attachment":
attachment = message.attachments
if len(attachment) == 0:
await self.safe_send_message(channel, "NO ATTACHMENT FOUND!")
else:
attachment = attachment[0]
song_url = attachment.url
if leftover_args:
song_url = ' '.join([song_url, *leftover_args])
leftover_args = None # prevent some crazy shit happening down the line

leftover_args = None # prevent some crazy shit happening down the line]
# Make sure forward slashes work properly in search queries
linksRegex = '((http(s)*:[/][/]|www.)([a-z]|[A-Z]|[0-9]|[/.]|[~])*)'
pattern = re.compile(linksRegex)
Expand Down Expand Up @@ -1904,7 +1938,7 @@ async def cmd_pause(self, player):

if player.is_playing:
player.pause()
return Response(self.str.get('cmd-pause-reply', 'Paused music in `{0.name}`').format(player.voice_client.channel))
return Response(self.str.get('cmd-pause-reply', 'Paused **{title}** ').format(title=player.current_entry.title),delete_after=15)

else:
raise exceptions.CommandError(self.str.get('cmd-pause-none', 'Player is not playing.'), expire_in=30)
Expand All @@ -1919,7 +1953,7 @@ async def cmd_resume(self, player):

if player.is_paused:
player.resume()
return Response(self.str.get('cmd-resume-reply', 'Resumed music in `{0.name}`').format(player.voice_client.channel), delete_after=15)
return Response(self.str.get('cmd-resume-reply', 'Resumed **{title}** ').format(title=player.current_entry.title), delete_after=15)

else:
raise exceptions.CommandError(self.str.get('cmd-resume-none', 'Player is not paused.'), expire_in=30)
Expand Down
41 changes: 41 additions & 0 deletions musicbot/test_plan_issues.txt
@@ -0,0 +1,41 @@
Issue 902 play embeded file in the chat
1. !play attachment without an attachment file
print out "NO ATTACHMENT FOUND" in the channel
2. !Play random words
search the song from the list is exsit or not
3. !play attachment with an attachment music file
put the music file in the playlist and play it after finishing the playlist
4. !play attachment with an attachment other file
show invalid content type

Issue 893 implement song title in commands
1.!pause you can see the song title implemented into the
pause command

2.!resume you can see the song title when the command
is called in the bot

Issue 1613 improvement on the help command
1. !help in the channel with the bot as a person with owner permissions
- view all 31 commands available to you formatted in an easy-to-read manner with bold numbers and underlined commands

2. !help in the channel with the bot as a person with non-owner permissions
- view all basic commmands available to you formatted in an easy-to-read manner with bold numbers and underlined commands

(the !help command can be executed on specific commmands but i did not touch that part of the function)

Group Issue switching playlist
(These tests must be executed while in the channel with the bot)
1. !plswitch filename given an existing file in the config folder with youtube urls
- the player should stop and swap to that playlist
- the swap can be proved successful if you run the !np commmand and you see it playing the first song on your list.

2. !plswitch filename with an non-existent filename or an empty txt file in the config folder
- the player will not stop your current playlist
- the player will print out an error message saying that the playlist is empty or non-existent

3. !plswitch filename given a file with non-youtube links or some other garbage text
- the player will not stop your current playlist
- an error message will print in discord saying that it failed to extract information from the url


13 changes: 6 additions & 7 deletions musicbot/utils.py
Expand Up @@ -60,13 +60,12 @@ def paginate(content, *, length=DISCORD_MSG_CHAR_LIMIT, reserve=0):


async def get_header(session, url, headerfield=None, *, timeout=5):
with aiohttp.Timeout(timeout):
async with session.head(url) as response:
if headerfield:
return response.headers.get(headerfield)
else:
return response.headers

#with aiohttp.Timeout(timeout):
async with session.head(url) as response:
if headerfield:
return response.headers.get(headerfield)
else:
return response.headers

def md5sum(filename, limit=0):
fhash = md5()
Expand Down