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

feat: add /nid command #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ send a `/help` command in you channel, Kyouka will teach you how to use.
- `/comehere`: bind the voice channel you are in.
- `/channel {channel_id}`: bind the voice channel with id.
- `/play {music_name}`: add a music to play list.
- `/nid {id}`: play the music which matches the provided ID from netease cloud music.
- `/search {keyword}`: search music by keyword from netease cloud music.
- `/msearch {keyword}`: search music by keyword from migu music.
- `/qsearch {keyword}`: search music by keyword from qq muisc.
Expand Down
1 change: 1 addition & 0 deletions README_ZH_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ python startup.py
- `/comehere`: 绑定你所在的语音频道
- `/channel {channel_id}`: 通过语音频道的ID进行绑定
- `/play {music_name}`: 点歌
- `/nid {id}`: 播放网易云上与指定 ID 对应的歌曲
- `/search {keyword}`: 搜索网易云音乐中的歌曲
- `/msearch {keyword}`: 搜索咪咕音乐中的歌曲
- `/qsearch {keyword}`: 搜索QQ音乐中的歌曲
Expand Down
1 change: 1 addition & 0 deletions app/CardStorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ def HelpCard() -> Card:
"""
:musical_note: **音乐指令** :musical_note:
`/play {music_name}` - 点歌
`/nid {id}`: 播放网易云上与指定 ID 对应的歌曲
`/search {keyword}` - 搜索歌曲
`/nsearch {keyword}` - 搜索网易云音乐中的歌曲
`/msearch {keyword}` - 搜索咪咕音乐中的歌曲
Expand Down
18 changes: 16 additions & 2 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from app.bot import bot
from app.config.common import settings
from app.music.netease.album import fetch_album_by_id
from app.music.netease.details import song_ids_to_instances
from app.music.netease.search import fetch_music_source_by_name, search_music_by_keyword
from app.music.netease.playlist import fetch_music_list_by_id
from app.music.netease.radio import fetch_radio_by_id
Expand Down Expand Up @@ -115,6 +116,19 @@ async def play_music(msg: Message, *args):
await msg.channel.send(f"没有搜索到歌曲: {music_name} 哦,试试搜索其他歌曲吧")


@bot.command(name="nid")
@log(command="nid")
@ban
@warn
async def play_music_using_netease_id(msg: Message, id: int):
music = await song_ids_to_instances(id)
if music:
await msg.channel.send(CardMessage(CS.pickCard(music)))
settings.playqueue.append(music)
else:
await msg.channel.send(f"没有找到 ID 为 {id} 的歌曲哦")


@bot.command(name='playlist', aliases=["歌单", "导入歌单"])
@log(command="playlist")
@ban
Expand Down Expand Up @@ -348,7 +362,7 @@ async def search_migu(msg: Message, *args):
await msg.reply(select_menu_msg)

else:
await msg.reply(f"没有任何与关键词: {keyword} 匹配的信息, 试试搜索其他关键字吧")
await msg.reply(f"没有任何与关键词: {keyword} 匹配的信息, 试试搜索其他关键字吧")


@bot.command(name='qsearch', aliases=['qq', 'qqsearch', 'searchqq', '搜索QQ', '搜QQ', 'QQ音乐'])
Expand Down Expand Up @@ -697,7 +711,7 @@ async def msg_btn_click(b:Bot,event:Event):

elif action == 'top':
top_number = int(args[0])

if top_number > play_list_length:
await update_cardmessage(message, CardMessage(CS.topCard(play_list[1:])))
else:
Expand Down