Skip to content

Conversation

@guohuiyuan
Copy link
Contributor

No description provided.

// 执行点播并返回结果
seg, err := getMusicSegment(targetPlatform, keyword)
if err != nil {
ctx.SendChain(message.Text("点歌失败:", err.Error()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ctx.SendChain(message.Text("点歌失败:", err.Error()))
ctx.SendChain(message.Text("点歌失败:", err))

)
// 平台映射:指令前缀 -> 平台名称
var platformMap = map[string]string{
"咪咕": "migu",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个中英互转没有意义,建议 key 直接放函数,如 "咪咕": getMiguMusic

// getMusicSegment 根据平台和关键词获取音乐消息段
func getMusicSegment(platform, keyword string) (message.Segment, error) {
switch platform {
case "migu":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里就不需要了

// 传入 &song (指针)
playURL, err := migu.GetDownloadURL(&song)
if err != nil || playURL == "" {
return message.Segment{}, errors.New("获取咪咕播放链接失败:" + err.Error())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里用 errors.Wrap(),其他同理。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants