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
8c71dbff
Commit
8c71dbff
authored
Aug 19, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
honor api supported.
parent
568b0e47
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
3 deletions
+72
-3
coolq/api.go
coolq/api.go
+55
-0
coolq/bot.go
coolq/bot.go
+4
-0
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-0
server/http.go
server/http.go
+7
-2
server/websocket.go
server/websocket.go
+3
-0
No files found.
coolq/api.go
View file @
8c71dbff
...
...
@@ -376,6 +376,61 @@ func (bot *CQBot) CQDeleteMessage(messageId int32) MSG {
return
OK
(
nil
)
}
// https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_group_honor_info-%E8%8E%B7%E5%8F%96%E7%BE%A4%E8%8D%A3%E8%AA%89%E4%BF%A1%E6%81%AF
func
(
bot
*
CQBot
)
CQGetGroupHonorInfo
(
groupId
int64
,
t
string
)
MSG
{
msg
:=
MSG
{
"group_id"
:
groupId
}
convertMem
:=
func
(
memList
[]
client
.
HonorMemberInfo
)
(
ret
[]
MSG
)
{
for
_
,
mem
:=
range
memList
{
ret
=
append
(
ret
,
MSG
{
"user_id"
:
mem
.
Uin
,
"nickname"
:
mem
.
Name
,
"avatar"
:
mem
.
Avatar
,
"description"
:
mem
.
Desc
,
})
}
return
}
if
t
==
"talkative"
||
t
==
"all"
{
if
honor
,
err
:=
bot
.
Client
.
GetGroupHonorInfo
(
groupId
,
client
.
Talkative
);
err
==
nil
{
if
honor
.
CurrentTalkative
.
Uin
!=
0
{
msg
[
"current_talkative"
]
=
MSG
{
"user_id"
:
honor
.
CurrentTalkative
.
Uin
,
"nickname"
:
honor
.
CurrentTalkative
.
Name
,
"avatar"
:
honor
.
CurrentTalkative
.
Avatar
,
"day_count"
:
honor
.
CurrentTalkative
.
DayCount
,
}
}
msg
[
"talkative_list"
]
=
convertMem
(
honor
.
TalkativeList
)
}
}
if
t
==
"performer"
||
t
==
"all"
{
if
honor
,
err
:=
bot
.
Client
.
GetGroupHonorInfo
(
groupId
,
client
.
Performer
);
err
==
nil
{
msg
[
"performer_lis"
]
=
convertMem
(
honor
.
ActorList
)
}
}
if
t
==
"legend"
||
t
==
"all"
{
if
honor
,
err
:=
bot
.
Client
.
GetGroupHonorInfo
(
groupId
,
client
.
Legend
);
err
==
nil
{
msg
[
"legend_list"
]
=
convertMem
(
honor
.
LegendList
)
}
}
if
t
==
"strong_newbie"
||
t
==
"all"
{
if
honor
,
err
:=
bot
.
Client
.
GetGroupHonorInfo
(
groupId
,
client
.
StrongNewbie
);
err
==
nil
{
msg
[
"strong_newbie_list"
]
=
convertMem
(
honor
.
StrongNewbieList
)
}
}
if
t
==
"emotion"
||
t
==
"all"
{
if
honor
,
err
:=
bot
.
Client
.
GetGroupHonorInfo
(
groupId
,
client
.
Emotion
);
err
==
nil
{
msg
[
"emotion_list"
]
=
convertMem
(
honor
.
EmotionList
)
}
}
return
OK
(
msg
)
}
// https://cqhttp.cc/docs/4.15/#/API?id=-handle_quick_operation-%E5%AF%B9%E4%BA%8B%E4%BB%B6%E6%89%A7%E8%A1%8C%E5%BF%AB%E9%80%9F%E6%93%8D%E4%BD%9C
// https://github.com/richardchien/coolq-http-api/blob/master/src/cqhttp/plugins/web/http.cpp#L376
func
(
bot
*
CQBot
)
CQHandleQuickOperation
(
context
,
operation
gjson
.
Result
)
MSG
{
...
...
coolq/bot.go
View file @
8c71dbff
...
...
@@ -117,6 +117,10 @@ func (bot *CQBot) SendGroupMessage(groupId int64, m *message.SendingMessage) int
}
m
.
Elements
=
newElem
ret
:=
bot
.
Client
.
SendGroupMessage
(
groupId
,
m
)
if
ret
.
Id
==
-
1
{
log
.
Warnf
(
"警告: 群 %v 消息发送失败, 账号可能被风控."
,
groupId
)
return
-
1
}
return
bot
.
InsertGroupMessage
(
ret
)
}
...
...
go.mod
View file @
8c71dbff
...
...
@@ -3,7 +3,7 @@ module github.com/Mrs4s/go-cqhttp
go 1.14
require (
github.com/Mrs4s/MiraiGo v0.0.0-2020081
7175311-ac7fc7ad2847
github.com/Mrs4s/MiraiGo v0.0.0-2020081
9041545-3561e5f156ce
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 @
8c71dbff
...
...
@@ -2,6 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Mrs4s/MiraiGo v0.0.0-20200817175311-ac7fc7ad2847 h1:ZnCHrRSLvN+a7ndOFPJF/FIg80JM6WxiOGC1TPTarEk=
github.com/Mrs4s/MiraiGo v0.0.0-20200817175311-ac7fc7ad2847/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
github.com/Mrs4s/MiraiGo v0.0.0-20200819041545-3561e5f156ce h1:rqefWaA8Xrk6qxFBbEQaySOUXH614DIR7cFmU5jVAQY=
github.com/Mrs4s/MiraiGo v0.0.0-20200819041545-3561e5f156ce/go.mod h1:0je03wji/tSw4bUH4QCF2Z4/EjyNWjSJTyy5tliX6EM=
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 @
8c71dbff
...
...
@@ -134,12 +134,12 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
s
.
engine
.
Any
(
"/set_group_leave_async"
,
s
.
SetGroupLeave
)
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
)
s
.
engine
.
Any
(
"/get_group_honor_info"
,
s
.
GetGroupHonorInfo
)
s
.
engine
.
Any
(
"/can_send_image"
,
s
.
CanSendImage
)
s
.
engine
.
Any
(
"/can_send_image_async"
,
s
.
CanSendImage
)
...
...
@@ -285,6 +285,11 @@ func (s *httpServer) GetGroupMessage(c *gin.Context) {
c
.
JSON
(
200
,
s
.
bot
.
CQGetGroupMessage
(
int32
(
mid
)))
}
func
(
s
*
httpServer
)
GetGroupHonorInfo
(
c
*
gin
.
Context
)
{
gid
,
_
:=
strconv
.
ParseInt
(
getParam
(
c
,
"group_id"
),
10
,
64
)
c
.
JSON
(
200
,
s
.
bot
.
CQGetGroupHonorInfo
(
gid
,
getParam
(
c
,
"type"
)))
}
func
(
s
*
httpServer
)
ProcessFriendRequest
(
c
*
gin
.
Context
)
{
flag
:=
getParam
(
c
,
"flag"
)
approve
:=
getParamOrDefault
(
c
,
"approve"
,
"true"
)
...
...
server/websocket.go
View file @
8c71dbff
...
...
@@ -422,6 +422,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
"get_group_msg"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQGetGroupMessage
(
int32
(
p
.
Get
(
"message_id"
)
.
Int
()))
},
"get_group_honor_info"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQGetGroupHonorInfo
(
p
.
Get
(
"group_id"
)
.
Int
(),
p
.
Get
(
"type"
)
.
Str
)
},
"can_send_image"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQCanSendImage
()
},
...
...
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