MCPcopy Create free account
hub / github.com/diillson/chatcli / runChannelRules

Method runChannelRules

cli/channel_command.go:178–220  ·  view source on GitHub ↗

runChannelRules shows the active rule set and supports a `rules reload` subcommand to re-read the config file.

(args []string)

Source from the content-addressed store, hash-verified

176// runChannelRules shows the active rule set and supports a
177// `rules reload` subcommand to re-read the config file.
178func (cli *ChatCLI) runChannelRules(args []string) {
179 if len(args) >= 3 && args[2] == "reload" {
180 n, err := cli.reloadChannelTriggerRules()
181 if err != nil {
182 fmt.Println(colorize(" ✗ "+err.Error(), ColorYellow))
183 return
184 }
185 fmt.Println(colorize(" ✓ "+i18n.T("chan.cmd.rules_reloaded", n), ColorGreen))
186 return
187 }
188 rules := cli.channelTriggerRules()
189 fmt.Println()
190 fmt.Println(uiBox("⚙", i18n.T("chan.cmd.rules_title"), ColorBlue))
191 p := uiPrefix(ColorBlue)
192 if len(rules) == 0 {
193 fmt.Println(p + colorize(i18n.T("chan.cmd.rules_empty"), ColorGray))
194 } else {
195 for _, r := range rules {
196 mode := string(r.Mode)
197 if mode == "" {
198 mode = "notify"
199 }
200 fmt.Println(p + fmt.Sprintf(" %s%s%s [%s] server=%s channel=%s",
201 ColorYellow, r.Name, ColorReset,
202 mode, defaultIfEmpty(r.Server, "*"), defaultIfEmpty(r.Channel, "*")))
203 if r.ContentRegex != "" {
204 fmt.Println(p + fmt.Sprintf(" %scontentRegex:%s %s",
205 ColorGray, ColorReset, r.ContentRegex))
206 }
207 if r.RateLimitTxt != "" || r.DedupTxt != "" {
208 fmt.Println(p + fmt.Sprintf(" %srate:%s %s %sdedup:%s %s",
209 ColorGray, ColorReset, defaultIfEmpty(r.RateLimitTxt, "—"),
210 ColorGray, ColorReset, defaultIfEmpty(r.DedupTxt, "—")))
211 }
212 if len(r.Tools) > 0 {
213 fmt.Println(p + fmt.Sprintf(" %stools:%s %s",
214 ColorGray, ColorReset, strings.Join(r.Tools, ", ")))
215 }
216 }
217 }
218 fmt.Println(uiBoxEnd(ColorBlue))
219 fmt.Println()
220}
221
222// runChannelConfirm resolves a pending confirm action. Defaults to
223// accept when only the id is provided; explicit "no" denies it.

Callers 1

handleChannelCommandMethod · 0.95

Calls 9

channelTriggerRulesMethod · 0.95
TFunction · 0.92
colorizeFunction · 0.85
uiBoxFunction · 0.85
uiPrefixFunction · 0.85
defaultIfEmptyFunction · 0.85
uiBoxEndFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected