From c5a13116facaf424bd038e62c4bb0398c294e9e2 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Mon, 3 Jan 2022 07:37:35 -0500 Subject: [PATCH] roles: add help --- plugins/roles/roles.go | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/plugins/roles/roles.go b/plugins/roles/roles.go index 9dbcb7f..bb1ec36 100644 --- a/plugins/roles/roles.go +++ b/plugins/roles/roles.go @@ -2,6 +2,7 @@ package roles import ( "fmt" + "github.com/velour/catbase/bot/msg" "regexp" "strings" @@ -29,6 +30,8 @@ func New(b bot.Bot) *RolesPlugin { return p } +var rolesRegexp = regexp.MustCompile(`(?i)^lsroles\s?(?P.*)`) + func (p *RolesPlugin) Register() { p.h = bot.HandlerTable{ { @@ -39,17 +42,26 @@ func (p *RolesPlugin) Register() { }, { Kind: bot.Message, IsCmd: true, - Regex: regexp.MustCompile(`(?i)^lsroles\s?(?P.*)`), + Regex: rolesRegexp, HelpText: "Lists roles with an optional offering set specifier", Handler: p.lsRoles, }, { - Kind: bot.Message, IsCmd: true, - Regex: regexp.MustCompile(`(?i)^offering (?P.+)`), - HelpText: "Changes the current offering set", - Handler: p.setOffering, + Kind: bot.Help, IsCmd: true, + Regex: regexp.MustCompile(`.`), + HelpText: "Lists roles with an optional offering set specifier", + Handler: p.lsRoles, }, } + p.b.Register(p, bot.Help, func(c bot.Connector, k bot.Kind, m msg.Message, args ...interface{}) bool { + return p.lsRoles(bot.Request{ + Conn: c, + Kind: k, + Msg: m, + Values: bot.ParseValues(rolesRegexp, m.Body), + Args: args, + }) + }) p.b.RegisterTable(p, p.h) }