1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-06 12:03:50 +08:00

add: api _get_vip_info

This commit is contained in:
wdvxdr 2020-09-05 23:03:08 +08:00
parent d79cb0b536
commit b104b21ab9
3 changed files with 29 additions and 0 deletions

View File

@ -396,6 +396,24 @@ func (bot *CQBot) CQDeleteMessage(messageId int32) MSG {
return OK(nil) return OK(nil)
} }
func (bot *CQBot) CQGetVipInfo(userId int64) MSG {
msg := MSG{}
vip, err := bot.Client.GetVipInfo(userId)
if err != nil {
return Failed(100)
}
msg = MSG{
"user_id": vip.Uin,
"nickname": vip.Name,
"level": vip.Level,
"level_speed": vip.LevelSpeed,
"vip_level": vip.VipLevel,
"vip_growth_speed": vip.VipGrowthSpeed,
"vip_growth_total": vip.VipGrowthTotal,
}
return OK(msg)
}
// 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 // 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 { func (bot *CQBot) CQGetGroupHonorInfo(groupId int64, t string) MSG {
msg := MSG{"group_id": groupId} msg := MSG{"group_id": groupId}

View File

@ -154,6 +154,9 @@ func (s *httpServer) Run(addr, authToken string, bot *coolq.CQBot) {
s.engine.Any("/get_version_info", s.GetVersionInfo) s.engine.Any("/get_version_info", s.GetVersionInfo)
s.engine.Any("/get_version_info_async", s.GetVersionInfo) s.engine.Any("/get_version_info_async", s.GetVersionInfo)
s.engine.Any("/_get_vip_info", s.GetVipInfo)
s.engine.Any("/_get_vip_info_async", s.GetVipInfo)
s.engine.Any("/.handle_quick_operation", s.HandleQuickOperation) s.engine.Any("/.handle_quick_operation", s.HandleQuickOperation)
go func() { go func() {
@ -381,6 +384,11 @@ func (s *httpServer) GetVersionInfo(c *gin.Context) {
c.JSON(200, s.bot.CQGetVersionInfo()) c.JSON(200, s.bot.CQGetVersionInfo())
} }
func (s *httpServer) GetVipInfo(c *gin.Context) {
uid, _ := strconv.ParseInt(getParam(c, "user_id"), 10, 64)
c.JSON(200, s.bot.CQGetVipInfo(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)

View File

@ -506,6 +506,9 @@ var wsApi = map[string]func(*coolq.CQBot, gjson.Result) coolq.MSG{
"get_version_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG { "get_version_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
return bot.CQGetVersionInfo() return bot.CQGetVersionInfo()
}, },
"_get_vip_info": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
return bot.CQGetVipInfo(p.Get("user_id").Int())
},
".handle_quick_operation": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG { ".handle_quick_operation": func(bot *coolq.CQBot, p gjson.Result) coolq.MSG {
return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation")) return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation"))
}, },