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

Merge pull request #872 from MikeWang000000/dev

Add new feature 增加设置在线机型功能
This commit is contained in:
wdvxdr1123 2021-05-04 16:43:06 +08:00 committed by GitHub
commit 66017bffb6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 3 deletions

View File

@ -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 生成成功返回值
func OK(data interface{}) MSG {
return MSG{"data": data, "retcode": 0, "status": "ok"}

2
go.mod
View File

@ -4,7 +4,7 @@ go 1.16
require (
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-20210503094755-b12e45fea93c
github.com/dustin/go-humanize v1.0.0
github.com/gin-contrib/pprof v1.3.0
github.com/gin-gonic/gin v1.7.1

4
go.sum
View File

@ -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/go.mod h1:4a58ifQTEe2uwwsaqbh3i2un5/CBPg+At/qHpt18Tmk=
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-20210503071221-639ad0f36252/go.mod h1:NjiWhlvGxwv1ftOWIoiFa/OzklnAYI4YqNexFOKSZKw=
github.com/Mrs4s/MiraiGo v0.0.0-20210503094755-b12e45fea93c h1:6Nyn1XkDM7E3VOVg1yrWFEui7vm2SmGQbiY8WoJ+9U4=
github.com/Mrs4s/MiraiGo v0.0.0-20210503094755-b12e45fea93c/go.mod h1:NjiWhlvGxwv1ftOWIoiFa/OzklnAYI4YqNexFOKSZKw=
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/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

View File

@ -338,6 +338,14 @@ func handleQuickOperation(bot *coolq.CQBot, p resultGetter) coolq.MSG {
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的映射表
var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
"get_login_info": getLoginInfo,
@ -398,6 +406,8 @@ var API = map[string]func(*coolq.CQBot, resultGetter) coolq.MSG{
"set_group_anonymous_ban": setGroupAnonymousBan,
".handle_quick_operation": handleQuickOperation,
"qidian_get_account_info": getQiDianAccountInfo,
"_get_model_show": getModelShow,
"_set_model_show": setModelShow,
}
func (api *apiCaller) callAPI(action string, p resultGetter) coolq.MSG {