From c619ee7feb19ba512da607b31dbc0f150c99eafa Mon Sep 17 00:00:00 2001 From: Mrs4s <1844812067@qq.com> Date: Tue, 13 Oct 2020 14:40:49 +0800 Subject: [PATCH] fix private rich msg. --- coolq/bot.go | 34 ++++++++++++++++++++++++++++++++++ server/apiAdmin.go | 4 ++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/coolq/bot.go b/coolq/bot.go index cd4c84f..92258be 100644 --- a/coolq/bot.go +++ b/coolq/bot.go @@ -217,6 +217,40 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in newElem = append(newElem, fm) continue } + if i, ok := elem.(*QQMusicElement); ok { + var msgStyle uint32 = 4 + if i.MusicUrl == "" { + msgStyle = 0 // fix vip song + } + bot.Client.SendFriendRichMessage(target, 100497308, 1, msgStyle, client.RichClientInfo{ + Platform: 1, + SdkVersion: "0.0.0", + PackageName: "com.tencent.qqmusic", + Signature: "cbd27cd7c861227d013a25b2d10f0799", + }, &message.RichMessage{ + Title: i.Title, + Summary: i.Summary, + Url: i.Url, + PictureUrl: i.PictureUrl, + MusicUrl: i.MusicUrl, + }) + return 0 + } + if i, ok := elem.(*CloudMusicElement); ok { + bot.Client.SendFriendRichMessage(target, 100495085, 1, 4, client.RichClientInfo{ + Platform: 1, + SdkVersion: "0.0.0", + PackageName: "com.netease.cloudmusic", + Signature: "da6b069da1e2982db3e386233f68d76d", + }, &message.RichMessage{ + Title: i.Title, + Summary: i.Summary, + Url: i.Url, + PictureUrl: i.PictureUrl, + MusicUrl: i.MusicUrl, + }) + return 0 + } newElem = append(newElem, elem) } m.Elements = newElem diff --git a/server/apiAdmin.go b/server/apiAdmin.go index febb887..ada43b3 100644 --- a/server/apiAdmin.go +++ b/server/apiAdmin.go @@ -136,7 +136,7 @@ func (s *webServer) Dologin() { continue case client.SMSNeededError: log.Warnf("账号已开启设备锁, 按下 Enter 向手机 %v 发送短信验证码.", rsp.SMSPhone) - _, _ = s.Console.ReadString('\n') + readLine() if !cli.RequestSMS() { log.Warnf("发送验证码失败,可能是请求过于频繁.") time.Sleep(time.Second * 5) @@ -151,7 +151,7 @@ func (s *webServer) Dologin() { log.Warnf("1. 向手机 %v 发送短信验证码", rsp.SMSPhone) log.Warnf("2. 使用手机QQ扫码验证.") log.Warn("请输入(1 - 2): ") - text, _ = s.Console.ReadString('\n') + text = readLine() if strings.Contains(text, "1") { if !cli.RequestSMS() { log.Warnf("发送验证码失败,可能是请求过于频繁.")