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
ac5803a5
Commit
ac5803a5
authored
Sep 06, 2020
by
scjtqs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xml和json消息以及cq码上报支持.
富文本的xml和json的消息识别,依赖miraigo的pr
parent
828ca2ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
3 deletions
+26
-3
coolq/cqcode.go
coolq/cqcode.go
+26
-3
No files found.
coolq/cqcode.go
View file @
ac5803a5
...
@@ -51,9 +51,13 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
...
@@ -51,9 +51,13 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
"data"
:
map
[
string
]
string
{
"text"
:
o
.
Content
},
"data"
:
map
[
string
]
string
{
"text"
:
o
.
Content
},
}
}
case
*
message
.
LightAppElement
:
case
*
message
.
LightAppElement
:
//m = MSG{
// "type": "text",
// "data": map[string]string{"text": o.Content},
//}
m
=
MSG
{
m
=
MSG
{
"type"
:
"
text
"
,
"type"
:
"
json
"
,
"data"
:
map
[
string
]
string
{
"
text
"
:
o
.
Content
},
"data"
:
map
[
string
]
string
{
"
data
"
:
o
.
Content
},
}
}
case
*
message
.
AtElement
:
case
*
message
.
AtElement
:
if
o
.
Target
==
0
{
if
o
.
Target
==
0
{
...
@@ -113,6 +117,18 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
...
@@ -113,6 +117,18 @@ func ToArrayMessage(e []message.IMessageElement, code int64, raw ...bool) (r []M
"data"
:
map
[
string
]
string
{
"file"
:
o
.
Filename
,
"url"
:
o
.
Url
},
"data"
:
map
[
string
]
string
{
"file"
:
o
.
Filename
,
"url"
:
o
.
Url
},
}
}
}
}
case
*
message
.
ServiceElement
:
if
isOk
:=
strings
.
Contains
(
o
.
Content
,
"<?xml"
);
isOk
{
m
=
MSG
{
"type"
:
"xml"
,
"data"
:
map
[
string
]
string
{
"data"
:
o
.
Content
,
"resid"
:
fmt
.
Sprintf
(
"%d"
,
o
.
Id
)},
}
}
else
{
m
=
MSG
{
"type"
:
"json"
,
"data"
:
map
[
string
]
string
{
"data"
:
o
.
Content
,
"resid"
:
fmt
.
Sprintf
(
"%d"
,
o
.
Id
)},
}
}
}
}
r
=
append
(
r
,
m
)
r
=
append
(
r
,
m
)
}
}
...
@@ -165,8 +181,15 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st
...
@@ -165,8 +181,15 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st
}
else
{
}
else
{
r
+=
fmt
.
Sprintf
(
`[CQ:image,file=%s,url=%s]`
,
o
.
Filename
,
CQCodeEscapeValue
(
o
.
Url
))
r
+=
fmt
.
Sprintf
(
`[CQ:image,file=%s,url=%s]`
,
o
.
Filename
,
CQCodeEscapeValue
(
o
.
Url
))
}
}
case
*
message
.
ServiceElement
:
if
isOk
:=
strings
.
Contains
(
o
.
Content
,
"<?xml"
);
isOk
{
r
+=
fmt
.
Sprintf
(
`[CQ:xml,data=%s,resid=%d]`
,
CQCodeEscapeValue
(
o
.
Content
),
o
.
Id
)
}
else
{
r
+=
fmt
.
Sprintf
(
`[CQ:json,data=%s,resid=%d]`
,
CQCodeEscapeValue
(
o
.
Content
),
o
.
Id
)
}
case
*
message
.
LightAppElement
:
case
*
message
.
LightAppElement
:
r
+=
CQCodeEscapeText
(
o
.
Content
)
r
+=
fmt
.
Sprintf
(
`[CQ:json,data=%s]`
,
CQCodeEscapeValue
(
o
.
Content
))
//r += CQCodeEscapeText(o.Content)
}
}
}
}
return
return
...
...
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