mirror of https://github.com/velour/catbase.git
tldr: add squawk command
This commit is contained in:
parent
0397fa2897
commit
1743b65242
|
@ -57,10 +57,16 @@ func (p *TLDRPlugin) register() {
|
||||||
HelpText: "Get a rather inaccurate summary of the channel",
|
HelpText: "Get a rather inaccurate summary of the channel",
|
||||||
Handler: p.tldrCmd,
|
Handler: p.tldrCmd,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Kind: bot.Message, IsCmd: true,
|
||||||
|
Regex: regexp.MustCompile(`tl;?dr-prompt$`),
|
||||||
|
HelpText: "Get the tl;dr prompt",
|
||||||
|
Handler: p.squawkTLDR,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Kind: bot.Message, IsCmd: true,
|
Kind: bot.Message, IsCmd: true,
|
||||||
Regex: regexp.MustCompile(`tl;?dr-prompt reset`),
|
Regex: regexp.MustCompile(`tl;?dr-prompt reset`),
|
||||||
HelpText: "Set the tl;dr prompt",
|
HelpText: "Reset the tl;dr prompt",
|
||||||
Handler: p.resetTLDR,
|
Handler: p.resetTLDR,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -268,6 +274,13 @@ func (p *TLDRPlugin) betterTLDR(r bot.Request) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *TLDRPlugin) squawkTLDR(r bot.Request) bool {
|
||||||
|
prompt := p.c.Get(templateKey, defaultTemplate)
|
||||||
|
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, fmt.Sprintf(`Current prompt is: "%s"`,
|
||||||
|
strings.TrimSpace(prompt)))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (p *TLDRPlugin) resetTLDR(r bot.Request) bool {
|
func (p *TLDRPlugin) resetTLDR(r bot.Request) bool {
|
||||||
p.c.Set(templateKey, defaultTemplate)
|
p.c.Set(templateKey, defaultTemplate)
|
||||||
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, fmt.Sprintf(`Set prompt to: "%s"`,
|
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, fmt.Sprintf(`Set prompt to: "%s"`,
|
||||||
|
@ -278,7 +291,7 @@ func (p *TLDRPlugin) resetTLDR(r bot.Request) bool {
|
||||||
func (p *TLDRPlugin) setTLDR(r bot.Request) bool {
|
func (p *TLDRPlugin) setTLDR(r bot.Request) bool {
|
||||||
prompt := r.Values["prompt"] + "\n"
|
prompt := r.Values["prompt"] + "\n"
|
||||||
p.c.Set(defaultTemplate, prompt)
|
p.c.Set(defaultTemplate, prompt)
|
||||||
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, fmt.Sprintf(`Set prompt to: "%s"`, prompt))
|
p.b.Send(r.Conn, bot.Message, r.Msg.Channel, fmt.Sprintf(`Set prompt to: "%s"`, strings.TrimSpace(prompt)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue