mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-06 12:03:50 +08:00
Add new feature 增加设置在线机型功能
如iPad在线、iPhone在线、自定义机型在线等
This commit is contained in:
parent
605d8bb07d
commit
8ee342c871
31
coolq/api.go
31
coolq/api.go
@ -1380,6 +1380,37 @@ func (bot *CQBot) CQGetVersionInfo() MSG {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CQGetModelShow 获取在线机型
|
||||||
|
//
|
||||||
|
// https://club.vip.qq.com/onlinestatus/set
|
||||||
|
func (bot *CQBot) CQGetModelShow(modelName string) MSG {
|
||||||
|
variants, err := bot.Client.GetModelShow(modelName)
|
||||||
|
if err != nil {
|
||||||
|
return Failed(100, "GET_MODEL_SHOW_API_ERROR", "无法获取在线机型")
|
||||||
|
}
|
||||||
|
a := make([]MSG, 0, len(variants))
|
||||||
|
for _, v := range variants {
|
||||||
|
a = append(a, MSG{
|
||||||
|
"model_show": v.ModelShow,
|
||||||
|
"need_pay": v.NeedPay,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return OK(MSG{
|
||||||
|
"variants": a,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// CQSetModelShow 设置在线机型
|
||||||
|
//
|
||||||
|
// https://club.vip.qq.com/onlinestatus/set
|
||||||
|
func (bot *CQBot) CQSetModelShow(modelName string, modelShow string) MSG {
|
||||||
|
err := bot.Client.SetModelShow(modelName, modelShow)
|
||||||
|
if err != nil {
|
||||||
|
return Failed(100, "SET_MODEL_SHOW_API_ERROR", "无法设置在线机型")
|
||||||
|
}
|
||||||
|
return OK(nil)
|
||||||
|
}
|
||||||
|
|
||||||
// OK 生成成功返回值
|
// OK 生成成功返回值
|
||||||
func OK(data interface{}) MSG {
|
func OK(data interface{}) MSG {
|
||||||
return MSG{"data": data, "retcode": 0, "status": "ok"}
|
return MSG{"data": data, "retcode": 0, "status": "ok"}
|
||||||
|
2
go.mod
2
go.mod
@ -4,7 +4,7 @@ go 1.16
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20210503071221-639ad0f36252
|
github.com/Mrs4s/MiraiGo v0.0.0-20210503075307-f38f387f022f
|
||||||
github.com/dustin/go-humanize v1.0.0
|
github.com/dustin/go-humanize v1.0.0
|
||||||
github.com/gin-contrib/pprof v1.3.0
|
github.com/gin-contrib/pprof v1.3.0
|
||||||
github.com/gin-gonic/gin v1.7.1
|
github.com/gin-gonic/gin v1.7.1
|
||||||
|
4
go.sum
4
go.sum
@ -2,8 +2,8 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
|
|||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f h1:2dk3eOnYllh+wUOuDhOoC2vUVoJF/5z478ryJ+wzEII=
|
||||||
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
github.com/Baozisoftware/qrcode-terminal-go v0.0.0-20170407111555-c0650d8dff0f/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20210503071221-639ad0f36252 h1:RFu7crktREtwCipQAJgKd2ImPUjObzFiEnXs982FG3U=
|
github.com/Mrs4s/MiraiGo v0.0.0-20210503075307-f38f387f022f h1:3HGvGPHobZ9UVmCiyHPzCYlINMPAutYIDZHoMTFP5DY=
|
||||||
github.com/Mrs4s/MiraiGo v0.0.0-20210503071221-639ad0f36252/go.mod h1:NjiWhlvGxwv1ftOWIoiFa/OzklnAYI4YqNexFOKSZKw=
|
github.com/Mrs4s/MiraiGo v0.0.0-20210503075307-f38f387f022f/go.mod h1:NjiWhlvGxwv1ftOWIoiFa/OzklnAYI4YqNexFOKSZKw=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
@ -338,6 +338,14 @@ func handleQuickOperation(bot *coolq.CQBot, p resultGetter) coolq.MSG {
|
|||||||
return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation"))
|
return bot.CQHandleQuickOperation(p.Get("context"), p.Get("operation"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getModelShow(bot *coolq.CQBot, p resultGetter) coolq.MSG {
|
||||||
|
return bot.CQGetModelShow(p.Get("model").String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func setModelShow(bot *coolq.CQBot, p resultGetter) coolq.MSG {
|
||||||
|
return bot.CQSetModelShow(p.Get("model").String(), p.Get("model_show").String())
|
||||||
|
}
|
||||||
|
|
||||||
// API 是go-cqhttp当前支持的所有api的映射表
|
// API 是go-cqhttp当前支持的所有api的映射表
|
||||||
var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
|
var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
|
||||||
"get_login_info": getLoginInfo,
|
"get_login_info": getLoginInfo,
|
||||||
@ -398,6 +406,8 @@ var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
|
|||||||
"set_group_anonymous_ban": setGroupAnonymousBan,
|
"set_group_anonymous_ban": setGroupAnonymousBan,
|
||||||
".handle_quick_operation": handleQuickOperation,
|
".handle_quick_operation": handleQuickOperation,
|
||||||
"qidian_get_account_info": getQiDianAccountInfo,
|
"qidian_get_account_info": getQiDianAccountInfo,
|
||||||
|
"_get_model_show": getModelShow,
|
||||||
|
"_set_model_show": setModelShow,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api *apiCaller) callAPI(action string, p resultGetter) coolq.MSG {
|
func (api *apiCaller) callAPI(action string, p resultGetter) coolq.MSG {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user