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
bb033159
Commit
bb033159
authored
Aug 12, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try to support escape again. #9
parent
5683db63
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
3 deletions
+15
-3
coolq/cqcode.go
coolq/cqcode.go
+15
-3
No files found.
coolq/cqcode.go
View file @
bb033159
...
@@ -118,13 +118,13 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st
...
@@ -118,13 +118,13 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st
if
ur
{
if
ur
{
r
+=
fmt
.
Sprintf
(
`[CQ:record,file=%s]`
,
o
.
Name
)
r
+=
fmt
.
Sprintf
(
`[CQ:record,file=%s]`
,
o
.
Name
)
}
else
{
}
else
{
r
+=
fmt
.
Sprintf
(
`[CQ:record,file=%s,url=%s]`
,
o
.
Name
,
o
.
Url
)
r
+=
fmt
.
Sprintf
(
`[CQ:record,file=%s,url=%s]`
,
o
.
Name
,
CQCodeEscapeValue
(
o
.
Url
)
)
}
}
case
*
message
.
ImageElement
:
case
*
message
.
ImageElement
:
if
ur
{
if
ur
{
r
+=
fmt
.
Sprintf
(
`[CQ:image,file=%s]`
,
o
.
Filename
)
r
+=
fmt
.
Sprintf
(
`[CQ:image,file=%s]`
,
o
.
Filename
)
}
else
{
}
else
{
r
+=
fmt
.
Sprintf
(
`[CQ:image,file=%s,url=%s]`
,
o
.
Filename
,
o
.
Url
)
r
+=
fmt
.
Sprintf
(
`[CQ:image,file=%s,url=%s]`
,
o
.
Filename
,
CQCodeEscapeValue
(
o
.
Url
)
)
}
}
}
}
}
}
...
@@ -145,7 +145,7 @@ func (bot *CQBot) ConvertStringMessage(m string, group bool) (r []message.IMessa
...
@@ -145,7 +145,7 @@ func (bot *CQBot) ConvertStringMessage(m string, group bool) (r []message.IMessa
ps
:=
paramReg
.
FindAllStringSubmatch
(
code
,
-
1
)
ps
:=
paramReg
.
FindAllStringSubmatch
(
code
,
-
1
)
d
:=
make
(
map
[
string
]
string
)
d
:=
make
(
map
[
string
]
string
)
for
_
,
p
:=
range
ps
{
for
_
,
p
:=
range
ps
{
d
[
p
[
1
]]
=
p
[
2
]
d
[
p
[
1
]]
=
CQCodeUnescapeValue
(
p
[
2
])
}
}
if
t
==
"reply"
&&
group
{
if
t
==
"reply"
&&
group
{
if
len
(
r
)
>
0
{
if
len
(
r
)
>
0
{
...
@@ -399,6 +399,12 @@ func CQCodeEscapeText(raw string) string {
...
@@ -399,6 +399,12 @@ func CQCodeEscapeText(raw string) string {
return
ret
return
ret
}
}
func
CQCodeEscapeValue
(
value
string
)
string
{
ret
:=
CQCodeEscapeText
(
value
)
ret
=
strings
.
ReplaceAll
(
ret
,
","
,
","
)
return
ret
}
func
CQCodeUnescapeText
(
content
string
)
string
{
func
CQCodeUnescapeText
(
content
string
)
string
{
ret
:=
content
ret
:=
content
ret
=
strings
.
ReplaceAll
(
ret
,
"["
,
"["
)
ret
=
strings
.
ReplaceAll
(
ret
,
"["
,
"["
)
...
@@ -406,3 +412,9 @@ func CQCodeUnescapeText(content string) string {
...
@@ -406,3 +412,9 @@ func CQCodeUnescapeText(content string) string {
ret
=
strings
.
ReplaceAll
(
ret
,
"&"
,
"&"
)
ret
=
strings
.
ReplaceAll
(
ret
,
"&"
,
"&"
)
return
ret
return
ret
}
}
func
CQCodeUnescapeValue
(
content
string
)
string
{
ret
:=
CQCodeUnescapeText
(
content
)
ret
=
strings
.
ReplaceAll
(
ret
,
","
,
","
)
return
ret
}
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