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
557400b3
Commit
557400b3
authored
Jul 27, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forward message supported.
parent
0a6ddb08
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
5 deletions
+53
-5
coolq/api.go
coolq/api.go
+22
-0
coolq/cqcode.go
coolq/cqcode.go
+2
-0
docs/config.md
docs/config.md
+2
-1
docs/cqhttp.md
docs/cqhttp.md
+14
-3
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-0
server/http.go
server/http.go
+7
-0
server/websocket.go
server/websocket.go
+3
-0
No files found.
coolq/api.go
View file @
557400b3
...
...
@@ -307,6 +307,28 @@ func (bot *CQBot) CQGetImage(file string) MSG {
return
Failed
(
100
)
}
func
(
bot
*
CQBot
)
CQGetForwardMessage
(
resId
string
)
MSG
{
m
:=
bot
.
Client
.
GetForwardMessage
(
resId
)
if
m
==
nil
{
return
Failed
(
100
)
}
var
r
[]
MSG
for
_
,
n
:=
range
m
.
Nodes
{
checkImage
(
n
.
Message
)
r
=
append
(
r
,
MSG
{
"sender"
:
MSG
{
"user_id"
:
n
.
SenderId
,
"nick"
:
n
.
SenderName
,
},
"time"
:
n
.
Time
,
"content"
:
ToStringMessage
(
n
.
Message
,
0
,
false
),
})
}
return
OK
(
MSG
{
"messages"
:
r
,
})
}
func
(
bot
*
CQBot
)
CQGetGroupMessage
(
messageId
int32
)
MSG
{
msg
:=
bot
.
GetGroupMessage
(
messageId
)
if
msg
==
nil
{
...
...
coolq/cqcode.go
View file @
557400b3
...
...
@@ -36,6 +36,8 @@ func ToStringMessage(e []message.IMessageElement, code int64, raw ...bool) (r st
r
+=
fmt
.
Sprintf
(
"[CQ:at,qq=%d]"
,
o
.
Target
)
case
*
message
.
ReplyElement
:
r
+=
fmt
.
Sprintf
(
"[CQ:reply,id=%d]"
,
ToGlobalId
(
code
,
o
.
ReplySeq
))
case
*
message
.
ForwardElement
:
r
+=
fmt
.
Sprintf
(
"[CQ:forward,id=%s]"
,
o
.
ResId
)
case
*
message
.
FaceElement
:
r
+=
fmt
.
Sprintf
(
`[CQ:face,id=%d]`
,
o
.
Index
)
case
*
message
.
ImageElement
:
...
...
docs/config.md
View file @
557400b3
...
...
@@ -25,7 +25,8 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
"http_config"
:
{
"enabled"
:
true
,
"host"
:
"0.0.0.0"
,
"port"
:
5700
"port"
:
5700
,
"post_urls"
:
[]
},
"ws_config"
:
{
"enabled"
:
true
,
...
...
docs/cqhttp.md
View file @
557400b3
...
...
@@ -4,9 +4,10 @@
## CQCode
| Code | 示例 | 说明 |
| ----- | -------------------- | ---------------------------------------------------------- |
| reply | [CQ:reply,id=123456] | 回复ID为
`123456`
的信息. 发送时一条
`message`
仅能使用一次 |
| Code | 示例 | 说明 |
| ------- | -------------------- | ------------------------------------------------------------ |
| reply | [CQ:reply,id=123456] | 回复ID为
`123456`
的信息. 发送时一条
`message`
仅能使用一次 |
| forward | [CQ:forward,id=abcd] | ID为abcd的转发消息, 暂时仅能接收. 可通过
`/get_forward_msg`
API获取具体信息 |
## API
...
...
@@ -55,6 +56,16 @@
|
`time`
| int32 | 发送时间 |
|
`content`
| message | 消息内容 |
`/get_forward_msg`
**获取转发消息信息**
参数
| 字段 | 类型 | 说明 |
| ------------ | ------ | ------ |
|
`message_id`
| string | 消息id |
## 事件
#### 群消息撤回
...
...
go.mod
View file @
557400b3
...
...
@@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-2020072
1195252-2accd73f8b8e
github.com/Mrs4s/MiraiGo v0.0.0-2020072
6203306-14d741fe9383
github.com/gin-gonic/gin v1.6.3
github.com/gorilla/websocket v1.4.2
github.com/guonaihong/gout v0.1.1
...
...
go.sum
View file @
557400b3
...
...
@@ -14,6 +14,8 @@ github.com/Mrs4s/MiraiGo v0.0.0-20200720231612-a7e460246fbc h1:elEjdwOy2u+Gfz+1U
github.com/Mrs4s/MiraiGo v0.0.0-20200720231612-a7e460246fbc/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
github.com/Mrs4s/MiraiGo v0.0.0-20200721195252-2accd73f8b8e h1:68ol9TpLBwbFQU+S6VQ0CY6nQqN2xIPxHWD/rvBZxVI=
github.com/Mrs4s/MiraiGo v0.0.0-20200721195252-2accd73f8b8e/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
github.com/Mrs4s/MiraiGo v0.0.0-20200726203306-14d741fe9383 h1:Z1z7pG9RJo5ynI1mW0r+PyK9wZ6xExY8cMS+kV0NUJ0=
github.com/Mrs4s/MiraiGo v0.0.0-20200726203306-14d741fe9383/go.mod h1:M9wh1hjd0rie3+wm27tjPZkYMbD+MBV76CGqp2G7WSU=
github.com/bwmarrin/snowflake v0.3.0 h1:xm67bEhkKh6ij1790JB83OujPR5CzNe8QuQqAgISZN0=
github.com/bwmarrin/snowflake v0.3.0/go.mod h1:NdZxfVWX+oR6y2K0o6qAYv6gIOP9rjG0/E9WsDpxqwE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
...
...
server/http.go
View file @
557400b3
...
...
@@ -127,6 +127,8 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
s
.
engine
.
Any
(
"/get_image"
,
s
.
GetImage
)
s
.
engine
.
Any
(
"/get_image_async"
,
s
.
GetImage
)
s
.
engine
.
Any
(
"/get_forward_msg"
,
s
.
GetForwardMessage
)
s
.
engine
.
Any
(
"/get_group_msg"
,
s
.
GetGroupMessage
)
s
.
engine
.
Any
(
"/get_group_msg_async"
,
s
.
GetGroupMessage
)
...
...
@@ -298,6 +300,11 @@ func (s *httpServer) SetGroupName(c *gin.Context) {
c
.
JSON
(
200
,
s
.
bot
.
CQSetGroupName
(
gid
,
getParam
(
c
,
"name"
)))
}
func
(
s
*
httpServer
)
GetForwardMessage
(
c
*
gin
.
Context
)
{
resId
:=
getParam
(
c
,
"message_id"
)
c
.
JSON
(
200
,
s
.
bot
.
CQGetForwardMessage
(
resId
))
}
func
(
s
*
httpServer
)
DeleteMessage
(
c
*
gin
.
Context
)
{
mid
,
_
:=
strconv
.
ParseInt
(
getParam
(
c
,
"message_id"
),
10
,
32
)
c
.
JSON
(
200
,
s
.
bot
.
CQDeleteMessage
(
int32
(
mid
)))
...
...
server/websocket.go
View file @
557400b3
...
...
@@ -380,6 +380,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
"get_image"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQGetImage
(
p
.
Get
(
"file"
)
.
Str
)
},
"get_forward_msg"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQGetForwardMessage
(
p
.
Get
(
"message_id"
)
.
Str
)
},
"get_group_msg"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQGetGroupMessage
(
int32
(
p
.
Get
(
"message_id"
)
.
Int
()))
},
...
...
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