feat: enhance help inform structure and update command descriptions across various handlers
This commit is contained in:
parent
48dd4b17de
commit
a79991c4ff
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterFrontMatchHandler("用户权限", setUserLevel, constants.LEVEL_USER)
|
handler.RegisterFrontMatchHandler("用户权限", setUserLevel, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("用户权限", "用户权限 [用户] [权限] 设置用户权限。允许的权限有:根用户、管理员、信任、用户、拉黑、忽略")
|
handler.RegisterHelpInform("用户权限 [用户] [权限]", "用户权限", "设置用户权限。允许的权限有:根用户、管理员、信任、用户、拉黑、忽略")
|
||||||
}
|
}
|
||||||
|
|
||||||
var userLevelMap = map[string]constants.PermissionLevel{
|
var userLevelMap = map[string]constants.PermissionLevel{
|
||||||
|
@ -12,18 +12,18 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("查bl", getMyBL, constants.LEVEL_USER)
|
handler.RegisterHandler("查bl", getMyBL, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("查bl", "查看您的最新分数")
|
handler.RegisterHelpInform("查bl", "beatleader", "查bl 查看您的最新分数")
|
||||||
handler.RegisterHandler("绑定bl", bindBL, constants.LEVEL_USER)
|
handler.RegisterHandler("绑定bl", bindBL, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("绑定bl", "绑定您的beatleader账号")
|
handler.RegisterHelpInform("绑定bl", "beatleader", "绑定bl 绑定您的beatleader账号")
|
||||||
handler.RegisterHandler("解绑bl", unbindBL, constants.LEVEL_USER)
|
handler.RegisterHandler("解绑bl", unbindBL, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("解绑bl", "解绑您的beatleader账号")
|
handler.RegisterHelpInform("解绑bl", "beatleader", "解绑bl 解绑您的beatleader账号")
|
||||||
handler.RegisterHandler("最新bl", getMyRecentScore, constants.LEVEL_USER)
|
handler.RegisterHandler("最新bl", getMyRecentScore, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("最新bl", "查看您的最新游戏记录")
|
handler.RegisterHelpInform("最新bl", "beatleader", "最新bl 查看您的最新游戏记录")
|
||||||
handler.RegisterHandler("最热bl", getRecentScore, constants.LEVEL_USER)
|
handler.RegisterHandler("最热bl", getRecentScore, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("最热bl", "查看全大陆的最新游戏记录")
|
handler.RegisterHelpInform("最热bl", "beatleader", "最热bl 查看全大陆的最新游戏记录")
|
||||||
handler.RegisterHandler("截bl", screenShotBL, constants.LEVEL_USER)
|
handler.RegisterHandler("截bl", screenShotBL, constants.LEVEL_USER)
|
||||||
|
handler.RegisterHelpInform("截bl", "beatleader", "截bl 截bl 截bl主页截图")
|
||||||
handler.RegisterHandler("jbl", screenShotBL, constants.LEVEL_USER)
|
handler.RegisterHandler("jbl", screenShotBL, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("截bl/jbl", "beatleader主页截图")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMyBL(msg model.Message) (reply model.Reply) {
|
func getMyBL(msg model.Message) (reply model.Reply) {
|
||||||
|
@ -14,7 +14,7 @@ var userGameMap map[string]*core.BackJackGame
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("bj", blackJack, constants.LEVEL_USER)
|
handler.RegisterHandler("bj", blackJack, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("bj start", "Play a game of blackjack")
|
handler.RegisterHelpInform("bj", "blackjack", "bj start 开始玩黑杰克")
|
||||||
userGameMap = make(map[string]*core.BackJackGame)
|
userGameMap = make(map[string]*core.BackJackGame)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterRegexHandler(`撤回`, drawback, constants.LEVEL_USER)
|
handler.RegisterRegexHandler(`撤回`, drawback, constants.LEVEL_USER)
|
||||||
|
handler.RegisterHelpInform("撤回", "drawback", "发送 <引用消息>撤回 撤回消息")
|
||||||
}
|
}
|
||||||
|
|
||||||
func drawback(msg model.Message) model.Reply {
|
func drawback(msg model.Message) model.Reply {
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("echo", echo, constants.LEVEL_USER)
|
handler.RegisterHandler("echo", echo, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("echo", "再说一遍")
|
handler.RegisterHelpInform("echo", "echo", "echo <message> 再说一遍")
|
||||||
}
|
}
|
||||||
|
|
||||||
func echo(msg model.Message) (reply model.Reply) {
|
func echo(msg model.Message) (reply model.Reply) {
|
||||||
|
@ -13,9 +13,9 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("exec", runInDocker, constants.LEVEL_USER)
|
handler.RegisterHandler("exec", runInDocker, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("exec", "执行命令")
|
handler.RegisterHelpInform("exec", "docker", "exec <command> 执行命令")
|
||||||
handler.RegisterHandler("reboot", restartDocker, constants.LEVEL_USER)
|
handler.RegisterHandler("reboot", restartDocker, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("reboot", "重启环境")
|
handler.RegisterHelpInform("reboot", "docker", "reboot 重启环境")
|
||||||
}
|
}
|
||||||
|
|
||||||
func runInDocker(msg model.Message) (reply model.Reply) {
|
func runInDocker(msg model.Message) (reply model.Reply) {
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
package getweb
|
package getweb
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"git.lxtend.com/qqbot/constants"
|
|
||||||
"git.lxtend.com/qqbot/handler"
|
|
||||||
"git.lxtend.com/qqbot/model"
|
"git.lxtend.com/qqbot/model"
|
||||||
"git.lxtend.com/qqbot/util"
|
"git.lxtend.com/qqbot/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("上网", getweb, constants.LEVEL_TRUSTED)
|
// handler.RegisterHandler("上网", getweb, constants.LEVEL_TRUSTED)
|
||||||
handler.RegisterHelpInform("上网", "上网 <URL> 截取网页")
|
// handler.RegisterHelpInform("上网", "getweb", "上网 <URL> 截取网页")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getweb(msg model.Message) (reply model.Reply) {
|
func getweb(msg model.Message) (reply model.Reply) {
|
||||||
|
@ -16,7 +16,8 @@ var frontMatchHandlers = make(map[string]model.HandlerInfo[model.Handler])
|
|||||||
var regexHandlers = make(map[string]model.HandlerInfo[model.Handler])
|
var regexHandlers = make(map[string]model.HandlerInfo[model.Handler])
|
||||||
var liveHandlers = make(map[int64]map[int64]model.TryCatchHandler)
|
var liveHandlers = make(map[int64]map[int64]model.TryCatchHandler)
|
||||||
var livePrivateHandlers = make(map[int64]model.TryCatchHandler)
|
var livePrivateHandlers = make(map[int64]model.TryCatchHandler)
|
||||||
var HelpInforms = make(map[string]string)
|
|
||||||
|
var HelpInforms = make(map[string][]model.HelpInform)
|
||||||
var privateAllHandler model.Handler
|
var privateAllHandler model.Handler
|
||||||
|
|
||||||
func RegisterPrivateHandler(handler model.Handler) {
|
func RegisterPrivateHandler(handler model.Handler) {
|
||||||
@ -141,6 +142,12 @@ func MsgInHandler(msg model.Message) (reply model.Reply) {
|
|||||||
return model.Reply{}
|
return model.Reply{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func RegisterHelpInform(triggerName string, inform string) {
|
func RegisterHelpInform(triggerName string, category string, inform string) {
|
||||||
HelpInforms[triggerName] = inform
|
if _, ok := HelpInforms[triggerName]; !ok {
|
||||||
|
HelpInforms[triggerName] = []model.HelpInform{}
|
||||||
|
}
|
||||||
|
HelpInforms[triggerName] = append(HelpInforms[triggerName], model.HelpInform{
|
||||||
|
Trigger: triggerName,
|
||||||
|
Inform: inform,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import (
|
|||||||
"git.lxtend.com/qqbot/constants"
|
"git.lxtend.com/qqbot/constants"
|
||||||
"git.lxtend.com/qqbot/handler"
|
"git.lxtend.com/qqbot/handler"
|
||||||
"git.lxtend.com/qqbot/model"
|
"git.lxtend.com/qqbot/model"
|
||||||
|
"git.lxtend.com/qqbot/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -11,9 +12,19 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func help(msg model.Message) (reply model.Reply) {
|
func help(msg model.Message) (reply model.Reply) {
|
||||||
helpInfo := `以下是支持的功能:`
|
var helpInfo string
|
||||||
for k, v := range handler.HelpInforms {
|
if len(util.SplitN(msg.RawMsg, 2)) == 1 {
|
||||||
helpInfo += "\n" + k + " : " + v
|
helpInfo = `!help [分类] 查看下面的分类功能`
|
||||||
|
for k := range handler.HelpInforms {
|
||||||
|
helpInfo += "\n" + k
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
category := util.SplitN(msg.RawMsg, 2)[1]
|
||||||
|
helpInfos := handler.HelpInforms[category]
|
||||||
|
helpInfo = `以下是` + category + `的功能:`
|
||||||
|
for _, v := range helpInfos {
|
||||||
|
helpInfo += "\n" + v.Trigger + " : " + v.Inform
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return model.Reply{
|
return model.Reply{
|
||||||
ReplyMsg: helpInfo,
|
ReplyMsg: helpInfo,
|
||||||
|
@ -15,7 +15,7 @@ func init() {
|
|||||||
jrrpInstance = jrrp.NewJrrp()
|
jrrpInstance = jrrp.NewJrrp()
|
||||||
handler.RegisterHandler("今日人品", jrrpHandler, constants.LEVEL_USER)
|
handler.RegisterHandler("今日人品", jrrpHandler, constants.LEVEL_USER)
|
||||||
handler.RegisterHandler("jrrp", jrrpHandler, constants.LEVEL_USER)
|
handler.RegisterHandler("jrrp", jrrpHandler, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("今日人品/jrrp", "今日人品或jrrp 查询今日人品")
|
handler.RegisterHelpInform("今日人品/jrrp", "今日人品", "查询今日人品")
|
||||||
}
|
}
|
||||||
|
|
||||||
func jrrpHandler(msg model.Message) (reply model.Reply) {
|
func jrrpHandler(msg model.Message) (reply model.Reply) {
|
||||||
|
@ -13,11 +13,11 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("kw", setKw, constants.LEVEL_TRUSTED)
|
handler.RegisterHandler("kw", setKw, constants.LEVEL_TRUSTED)
|
||||||
handler.RegisterHelpInform("kw", "kw [关键词] [回复内容] 添加关键词回复,kw [关键词] 删除全部关键词回复")
|
handler.RegisterHelpInform("kw [关键词] [回复内容]", "kw", "添加关键词回复,kw [关键词] 删除关键词下全部回复")
|
||||||
handler.RegisterHandler("kwd", deleteKw, constants.LEVEL_TRUSTED)
|
handler.RegisterHandler("kwd", deleteKw, constants.LEVEL_TRUSTED)
|
||||||
|
handler.RegisterHelpInform("kwd [关键词] [回复内容]", "kw", "删除关键词下指定回复")
|
||||||
handler.RegisterHandler("kwall", getGroupAllKW, constants.LEVEL_TRUSTED)
|
handler.RegisterHandler("kwall", getGroupAllKW, constants.LEVEL_TRUSTED)
|
||||||
handler.RegisterHelpInform("kwall", "kwall 查看所有关键词回复")
|
handler.RegisterHelpInform("kwall", "kw", "kwall 查看本群所有关键词回复")
|
||||||
initKw()
|
initKw()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,9 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("监听新债", listenBond, constants.LEVEL_USER)
|
handler.RegisterHandler("监听新债", listenBond, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("监听新债", "监听新债 开启新债监听")
|
handler.RegisterHelpInform("监听新债", "新债", "开启新债监听")
|
||||||
handler.RegisterHandler("取消监听新债", unListenBond, constants.LEVEL_USER)
|
handler.RegisterHandler("取消监听新债", unListenBond, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("取消监听新债", "取消监听新债 关闭新债监听")
|
handler.RegisterHelpInform("取消监听新债", "新债", "关闭新债监听")
|
||||||
}
|
}
|
||||||
|
|
||||||
func listenBond(msg model.Message) (reply model.Reply) {
|
func listenBond(msg model.Message) (reply model.Reply) {
|
||||||
|
@ -14,7 +14,7 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("roll", roll, constants.LEVEL_USER)
|
handler.RegisterHandler("roll", roll, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("roll", "roll点")
|
handler.RegisterHelpInform("roll [次数]d[面数]", "roll", "掷骰")
|
||||||
}
|
}
|
||||||
|
|
||||||
func roll(msg model.Message) (reply model.Reply) {
|
func roll(msg model.Message) (reply model.Reply) {
|
||||||
|
@ -13,18 +13,18 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("查ss", getSSProfile, constants.LEVEL_USER)
|
handler.RegisterHandler("查ss", getSSProfile, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("查ss", "查看您的最新分数")
|
handler.RegisterHelpInform("查ss", "scoresaber", " 查看您的最新分数")
|
||||||
handler.RegisterHandler("绑定ss", bindSS, constants.LEVEL_USER)
|
handler.RegisterHandler("绑定ss", bindSS, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("绑定ss", "绑定您的scoresaber账号")
|
handler.RegisterHelpInform("绑定ss", "scoresaber", "绑定您的scoresaber账号")
|
||||||
handler.RegisterHandler("解绑ss", unbindSS, constants.LEVEL_USER)
|
handler.RegisterHandler("解绑ss", unbindSS, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("解绑ss", "解绑您的scoresaber账号")
|
handler.RegisterHelpInform("解绑ss", "scoresaber", "解绑您的scoresaber账号")
|
||||||
handler.RegisterHandler("最新ss", getMyRecentScore, constants.LEVEL_USER)
|
handler.RegisterHandler("最新ss", getMyRecentScore, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("最新ss", "查看您的最新游戏记录")
|
handler.RegisterHelpInform("最新ss", "scoresaber", "查看您的最新游戏记录")
|
||||||
handler.RegisterHandler("最热ss", getRecentScore, constants.LEVEL_USER)
|
handler.RegisterHandler("最热ss", getRecentScore, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("最热ss", "查看全大陆的最新游戏记录")
|
handler.RegisterHelpInform("最热ss", "scoresaber", "查看全大陆的最新游戏记录")
|
||||||
handler.RegisterHandler("截ss", screenshotSS, constants.LEVEL_USER)
|
handler.RegisterHandler("截ss", screenshotSS, constants.LEVEL_USER)
|
||||||
|
handler.RegisterHelpInform("截ss", "scoresaber", "scoresaber主页截图")
|
||||||
handler.RegisterHandler("jss", screenshotSS, constants.LEVEL_USER)
|
handler.RegisterHandler("jss", screenshotSS, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("截ss/jss", "scoresaber主页截图")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getSSProfile(msg model.Message) (reply model.Reply) {
|
func getSSProfile(msg model.Message) (reply model.Reply) {
|
||||||
|
@ -15,17 +15,17 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
// Register the handler with the server
|
// Register the handler with the server
|
||||||
handler.RegisterHandler("绑steam", bindSteam, constants.LEVEL_USER)
|
handler.RegisterHandler("绑steam", bindSteam, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("绑steam", "绑定您的steam账号。可以通过右上角-账户明细页面 https://store.steampowered.com/account/ 查看,位于页面左上角")
|
handler.RegisterHelpInform("绑steam", "steam", "绑定您的steam账号。可以通过右上角-账户明细页面 https://store.steampowered.com/account/ 查看,位于页面左上角")
|
||||||
handler.RegisterHandler("群绑定steam", bindSteamInGroup, constants.LEVEL_USER)
|
handler.RegisterHandler("群绑定steam", bindSteamInGroup, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("群绑定steam", "在群内启用你的steam游戏状态查询")
|
handler.RegisterHelpInform("群绑定steam", "steam", "在群内启用你的steam游戏状态查询")
|
||||||
// handler.RegisterHandler("群通报steam", bindSteamInGroupBroadCast, constants.LEVEL_USER)
|
// handler.RegisterHandler("群通报steam", bindSteamInGroupBroadCast, constants.LEVEL_USER)
|
||||||
// handler.RegisterHelpInform("群通报steam", "在群内启用你的steam游戏上线通报")
|
// handler.RegisterHelpInform("群通报steam", "在群内启用你的steam游戏上线通报")
|
||||||
handler.RegisterHandler("解绑steam", unbindSteam, constants.LEVEL_USER)
|
handler.RegisterHandler("解绑steam", unbindSteam, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("解绑steam", "解绑您的steam账号,并解绑所有群监听")
|
handler.RegisterHelpInform("解绑steam", "steam", "解绑您的steam账号,并解绑所有群监听")
|
||||||
handler.RegisterHandler("群解绑steam", unbindSteamInGroup, constants.LEVEL_USER)
|
handler.RegisterHandler("群解绑steam", unbindSteamInGroup, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("群解绑steam", "解绑本群群监听steam游戏状态")
|
handler.RegisterHelpInform("群解绑steam", "steam", "解绑本群群监听steam游戏状态")
|
||||||
handler.RegisterHandler("查房", checkSteamPlaying, constants.LEVEL_USER)
|
handler.RegisterHandler("查房", checkSteamPlaying, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("查房", "查看群内成员的steam游戏状态")
|
handler.RegisterHelpInform("查房", "steam", "查看群内成员的steam游戏状态")
|
||||||
go RoundCheckSteamPlaying()
|
go RoundCheckSteamPlaying()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@ import (
|
|||||||
func init() {
|
func init() {
|
||||||
// Register the handler with the server
|
// Register the handler with the server
|
||||||
handler.RegisterHandler("提单", newTicket, constants.LEVEL_USER)
|
handler.RegisterHandler("提单", newTicket, constants.LEVEL_USER)
|
||||||
|
handler.RegisterHelpInform("提单 [内容]", "ticket", "提单")
|
||||||
handler.RegisterHandler("结单", doneTicket, constants.LEVEL_ROOT)
|
handler.RegisterHandler("结单", doneTicket, constants.LEVEL_ROOT)
|
||||||
|
handler.RegisterHelpInform("结单 [id]", "ticket", "结单")
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTicket(msg model.Message) model.Reply {
|
func newTicket(msg model.Message) model.Reply {
|
||||||
|
@ -13,9 +13,9 @@ import (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
handler.RegisterHandler("喜报", xiBao, constants.LEVEL_USER)
|
handler.RegisterHandler("喜报", xiBao, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("喜报", "喜报 [内容] 生成喜报图片,支持换行")
|
handler.RegisterHelpInform("喜报 [内容]", "喜报/悲报", "生成喜报图片,支持换行")
|
||||||
handler.RegisterHandler("悲报", beiBao, constants.LEVEL_USER)
|
handler.RegisterHandler("悲报", beiBao, constants.LEVEL_USER)
|
||||||
handler.RegisterHelpInform("悲报", "悲报 [内容] 生成悲报图片,支持换行")
|
handler.RegisterHelpInform("悲报 [内容]", "喜报/悲报", "生成悲报图片,支持换行")
|
||||||
}
|
}
|
||||||
|
|
||||||
func xiBao(msg model.Message) (reply model.Reply) {
|
func xiBao(msg model.Message) (reply model.Reply) {
|
||||||
|
6
model/help_inform.go
Normal file
6
model/help_inform.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
type HelpInform struct {
|
||||||
|
Trigger string
|
||||||
|
Inform string
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user