Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
go-cqhttp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
go-cqhttp
Commits
b99986d1
Commit
b99986d1
authored
Oct 17, 2020
by
wdvxdr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: support custom migu misic
parent
2302cf62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
coolq/bot.go
coolq/bot.go
+34
-0
coolq/cqcode.go
coolq/cqcode.go
+14
-0
No files found.
coolq/bot.go
View file @
b99986d1
...
...
@@ -190,6 +190,25 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int
}
return
bot
.
InsertGroupMessage
(
ret
)
}
if
i
,
ok
:=
elem
.
(
*
MiguMusicElement
);
ok
{
ret
,
err
:=
bot
.
Client
.
SendGroupRichMessage
(
groupId
,
1101053067
,
1
,
4
,
client
.
RichClientInfo
{
Platform
:
1
,
SdkVersion
:
"0.0.0"
,
PackageName
:
"cmccwm.mobilemusic"
,
Signature
:
"6cdc72a439cef99a3418d2a78aa28c73"
,
},
&
message
.
RichMessage
{
Title
:
i
.
Title
,
Summary
:
i
.
Summary
,
Url
:
i
.
Url
,
PictureUrl
:
i
.
PictureUrl
,
MusicUrl
:
i
.
MusicUrl
,
})
if
err
!=
nil
{
log
.
Warnf
(
"警告: 群 %v 富文本消息发送失败: %v"
,
groupId
,
err
)
return
-
1
}
return
bot
.
InsertGroupMessage
(
ret
)
}
newElem
=
append
(
newElem
,
elem
)
}
m
.
Elements
=
newElem
...
...
@@ -256,6 +275,21 @@ func (bot *CQBot) SendPrivateMessage(target int64, m *message.SendingMessage) in
})
return
0
}
if
i
,
ok
:=
elem
.
(
*
MiguMusicElement
);
ok
{
bot
.
Client
.
SendFriendRichMessage
(
target
,
1101053067
,
1
,
4
,
client
.
RichClientInfo
{
Platform
:
1
,
SdkVersion
:
"0.0.0"
,
PackageName
:
"cmccwm.mobilemusic"
,
Signature
:
"6cdc72a439cef99a3418d2a78aa28c73"
,
},
&
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
...
...
coolq/cqcode.go
View file @
b99986d1
...
...
@@ -51,6 +51,10 @@ type CloudMusicElement struct {
MusicElement
}
type
MiguMusicElement
struct
{
MusicElement
}
func
(
e
*
GiftElement
)
Type
()
message
.
ElementType
{
return
message
.
At
}
...
...
@@ -372,6 +376,7 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
return
nil
,
err
}
tp
:=
d
[
"type"
]
fmt
.
Println
(
tp
)
if
tp
!=
"show"
&&
tp
!=
"flash"
{
return
img
,
nil
}
...
...
@@ -536,6 +541,15 @@ func (bot *CQBot) ToElement(t string, d map[string]string, group bool) (m messag
MusicUrl
:
d
[
"purl"
],
}},
nil
}
if
d
[
"subtype"
]
==
"migu"
{
return
&
MiguMusicElement
{
MusicElement
{
Title
:
d
[
"title"
],
Summary
:
d
[
"content"
],
Url
:
d
[
"url"
],
PictureUrl
:
d
[
"image"
],
MusicUrl
:
d
[
"purl"
],
}},
nil
}
xml
:=
fmt
.
Sprintf
(
`<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><msg serviceID="2" templateID="1" action="web" brief="[分享] %s" sourceMsgId="0" url="%s" flag="0" adverSign="0" multiMsgFlag="0"><item layout="2"><audio cover="%s" src="%s"/><title>%s</title><summary>%s</summary></item><source name="音乐" icon="https://i.gtimg.cn/open/app_icon/01/07/98/56/1101079856_100_m.png" url="http://web.p.qq.com/qqmpmobile/aio/app.html?id=1101079856" action="app" a_actionData="com.tencent.qqmusic" i_actionData="tencent1101079856://" appid="1101079856" /></msg>`
,
d
[
"title"
],
d
[
"url"
],
d
[
"image"
],
d
[
"audio"
],
d
[
"title"
],
d
[
"content"
])
return
&
message
.
ServiceElement
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment