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
ea65e545
Commit
ea65e545
authored
Sep 19, 2020
by
Mrs4s
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
supported: get_stranger_info.
parent
d6762148
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
coolq/api.go
coolq/api.go
+21
-0
server/http.go
server/http.go
+8
-0
server/websocket.go
server/websocket.go
+3
-0
No files found.
coolq/api.go
View file @
ea65e545
...
@@ -497,6 +497,27 @@ func (bot *CQBot) CQGetGroupHonorInfo(groupId int64, t string) MSG {
...
@@ -497,6 +497,27 @@ func (bot *CQBot) CQGetGroupHonorInfo(groupId int64, t string) MSG {
return
OK
(
msg
)
return
OK
(
msg
)
}
}
// https://github.com/howmanybots/onebot/blob/master/v11/specs/api/public.md#get_stranger_info-%E8%8E%B7%E5%8F%96%E9%99%8C%E7%94%9F%E4%BA%BA%E4%BF%A1%E6%81%AF
func
(
bot
*
CQBot
)
CQGetStrangerInfo
(
userId
int64
)
MSG
{
info
,
err
:=
bot
.
Client
.
GetSummaryInfo
(
userId
)
if
err
!=
nil
{
return
Failed
(
100
)
}
return
OK
(
MSG
{
"user_id"
:
info
.
Uin
,
"nickname"
:
info
.
Nickname
,
"sex"
:
func
()
string
{
if
info
.
Sex
==
1
{
return
"female"
}
return
"male"
}(),
"age"
:
info
.
Age
,
"level"
:
info
.
Level
,
"login_days"
:
info
.
LoginDays
,
})
}
// 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://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
// 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
{
func
(
bot
*
CQBot
)
CQHandleQuickOperation
(
context
,
operation
gjson
.
Result
)
MSG
{
...
...
server/http.go
View file @
ea65e545
...
@@ -333,6 +333,11 @@ func (s *httpServer) GetVipInfo(c *gin.Context) {
...
@@ -333,6 +333,11 @@ func (s *httpServer) GetVipInfo(c *gin.Context) {
c
.
JSON
(
200
,
s
.
bot
.
CQGetVipInfo
(
uid
))
c
.
JSON
(
200
,
s
.
bot
.
CQGetVipInfo
(
uid
))
}
}
func
(
s
*
httpServer
)
GetStrangerInfo
(
c
*
gin
.
Context
)
{
uid
,
_
:=
strconv
.
ParseInt
(
getParam
(
c
,
"user_id"
),
10
,
64
)
c
.
JSON
(
200
,
s
.
bot
.
CQGetStrangerInfo
(
uid
))
}
func
(
s
*
httpServer
)
HandleQuickOperation
(
c
*
gin
.
Context
)
{
func
(
s
*
httpServer
)
HandleQuickOperation
(
c
*
gin
.
Context
)
{
if
c
.
Request
.
Method
!=
"POST"
{
if
c
.
Request
.
Method
!=
"POST"
{
c
.
AbortWithStatus
(
404
)
c
.
AbortWithStatus
(
404
)
...
@@ -486,6 +491,9 @@ var httpApi = map[string]func(s *httpServer, c *gin.Context){
...
@@ -486,6 +491,9 @@ var httpApi = map[string]func(s *httpServer, c *gin.Context){
"_get_vip_info"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
"_get_vip_info"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
GetVipInfo
(
c
)
s
.
GetVipInfo
(
c
)
},
},
"get_stranger_info"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
GetStrangerInfo
(
c
)
},
"reload_event_filter"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
"reload_event_filter"
:
func
(
s
*
httpServer
,
c
*
gin
.
Context
)
{
s
.
ReloadEventFilter
(
c
)
s
.
ReloadEventFilter
(
c
)
},
},
...
...
server/websocket.go
View file @
ea65e545
...
@@ -486,6 +486,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
...
@@ -486,6 +486,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
"can_send_record"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
"can_send_record"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQCanSendRecord
()
return
bot
.
CQCanSendRecord
()
},
},
"get_stranger_info"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQGetStrangerInfo
(
p
.
Get
(
"user_id"
)
.
Int
())
},
"get_status"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
"get_status"
:
func
(
bot
*
coolq
.
CQBot
,
p
gjson
.
Result
)
coolq
.
MSG
{
return
bot
.
CQGetStatus
()
return
bot
.
CQGetStatus
()
},
},
...
...
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