mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
supported: get_stranger_info.
This commit is contained in:
parent
d67621487d
commit
ea65e545ad
21
coolq/api.go
21
coolq/api.go
@ -497,6 +497,27 @@ func (bot *CQBot) CQGetGroupHonorInfo(groupId int64, t string) 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://github.com/richardchien/coolq-http-api/blob/master/src/cqhttp/plugins/web/http.cpp#L376
|
||||
func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG {
|
||||
|
@ -333,6 +333,11 @@ func (s *httpServer) GetVipInfo(c *gin.Context) {
|
||||
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) {
|
||||
if c.Request.Method != "POST" {
|
||||
c.AbortWithStatus(404)
|
||||
@ -486,6 +491,9 @@ var httpApi = map[string]func(s *httpServer, c *gin.Context){
|
||||
"_get_vip_info": func(s *httpServer, c *gin.Context) {
|
||||
s.GetVipInfo(c)
|
||||
},
|
||||
"get_stranger_info": func(s *httpServer, c *gin.Context) {
|
||||
s.GetStrangerInfo(c)
|
||||
},
|
||||
"reload_event_filter": func(s *httpServer, c *gin.Context) {
|
||||
s.ReloadEventFilter(c)
|
||||
},
|
||||
|
@ -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 {
|
||||
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 {
|
||||
return bot.CQGetStatus()
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user