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
a215028a
Commit
a215028a
authored
Jul 28, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
object message supported.
parent
d076f174
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
14 deletions
+20
-14
README.md
README.md
+1
-0
coolq/api.go
coolq/api.go
+4
-4
coolq/cqcode.go
coolq/cqcode.go
+13
-5
main.go
main.go
+2
-5
No files found.
README.md
View file @
a215028a
...
...
@@ -19,6 +19,7 @@
-
[x] 消息撤回事件
-
[x] 解析/发送 回复消息
-
[x] 解析 合并转发
-
[x] 使用代理请求网络图片
#### 实现
<details>
...
...
coolq/api.go
View file @
a215028a
...
...
@@ -108,8 +108,8 @@ func (bot *CQBot) CQSendGroupMessage(groupId int64, m gjson.Result) MSG {
}
return
OK
(
MSG
{
"message_id"
:
mid
})
}
if
m
.
IsArray
()
{
elem
:=
bot
.
Convert
Array
Message
(
m
,
true
)
if
m
.
Type
==
gjson
.
JSON
{
elem
:=
bot
.
Convert
Object
Message
(
m
,
true
)
mid
:=
bot
.
SendGroupMessage
(
groupId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
if
mid
==
-
1
{
return
Failed
(
100
)
...
...
@@ -130,8 +130,8 @@ func (bot *CQBot) CQSendPrivateMessage(userId int64, m gjson.Result) MSG {
}
return
OK
(
MSG
{
"message_id"
:
mid
})
}
if
m
.
IsArray
()
{
elem
:=
bot
.
Convert
Array
Message
(
m
,
true
)
if
m
.
Type
==
gjson
.
JSON
{
elem
:=
bot
.
Convert
Object
Message
(
m
,
true
)
mid
:=
bot
.
SendPrivateMessage
(
userId
,
&
message
.
SendingMessage
{
Elements
:
elem
})
if
mid
==
-
1
{
return
Failed
(
100
)
...
...
coolq/cqcode.go
View file @
a215028a
...
...
@@ -104,14 +104,14 @@ func (bot *CQBot) ConvertStringMessage(m string, group bool) (r []message.IMessa
return
}
func
(
bot
*
CQBot
)
Convert
Array
Message
(
m
gjson
.
Result
,
group
bool
)
(
r
[]
message
.
IMessageElement
)
{
for
_
,
e
:=
range
m
.
Array
(
)
{
func
(
bot
*
CQBot
)
Convert
Object
Message
(
m
gjson
.
Result
,
group
bool
)
(
r
[]
message
.
IMessageElement
)
{
convertElem
:=
func
(
e
gjson
.
Result
)
{
t
:=
e
.
Get
(
"type"
)
.
Str
if
t
==
"reply"
&&
group
{
if
len
(
r
)
>
0
{
if
_
,
ok
:=
r
[
0
]
.
(
*
message
.
ReplyElement
);
ok
{
log
.
Warnf
(
"警告: 一条信息只能包含一个 Reply 元素."
)
continue
return
}
}
mid
,
err
:=
strconv
.
Atoi
(
e
.
Get
(
"data"
)
.
Get
(
"id"
)
.
Str
)
...
...
@@ -126,7 +126,7 @@ func (bot *CQBot) ConvertArrayMessage(m gjson.Result, group bool) (r []message.I
Elements
:
bot
.
ConvertStringMessage
(
org
[
"message"
]
.
(
string
),
group
),
},
},
r
...
)
continue
return
}
}
}
...
...
@@ -138,10 +138,18 @@ func (bot *CQBot) ConvertArrayMessage(m gjson.Result, group bool) (r []message.I
elem
,
err
:=
bot
.
ToElement
(
t
,
d
,
group
)
if
err
!=
nil
{
log
.
Warnf
(
"转换CQ码到MiraiGo Element时出现错误: %v 将忽略本段CQ码."
,
err
)
continue
return
}
r
=
append
(
r
,
elem
)
}
if
m
.
IsArray
()
{
for
_
,
e
:=
range
m
.
Array
()
{
convertElem
(
e
)
}
}
if
m
.
IsObject
()
{
convertElem
(
m
)
}
return
}
...
...
main.go
View file @
a215028a
...
...
@@ -115,11 +115,8 @@ func main() {
rsp
,
err
=
cli
.
SubmitCaptcha
(
strings
.
ReplaceAll
(
text
,
"
\n
"
,
""
),
rsp
.
CaptchaSign
)
continue
case
client
.
UnsafeDeviceError
:
log
.
Warnf
(
"账号已开启设备锁,请前往 -> %v <- 验证."
,
rsp
.
VerifyUrl
)
log
.
Info
(
"按 Enter 继续"
)
_
,
_
=
console
.
ReadString
(
'\n'
)
rsp
,
err
=
cli
.
Login
()
continue
log
.
Warnf
(
"账号已开启设备锁,请前往 -> %v <- 验证并重启Bot."
,
rsp
.
VerifyUrl
)
return
case
client
.
OtherLoginError
,
client
.
UnknownLoginError
:
log
.
Fatalf
(
"登录失败: %v"
,
rsp
.
ErrorMessage
)
}
...
...
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