bot: disable suffix commands

This commit is contained in:
Chris Sexton 2021-01-09 17:22:47 -05:00 committed by Chris Sexton
parent c4605cfb77
commit 1acb78bb5a
1 changed files with 0 additions and 7 deletions

View File

@ -182,10 +182,6 @@ var suffixRegex *regexp.Regexp
func IsCmd(c *config.Config, message string) (bool, string) { func IsCmd(c *config.Config, message string) (bool, string) {
cmdcs := c.GetArray("CommandChar", []string{"!"}) cmdcs := c.GetArray("CommandChar", []string{"!"})
botnick := strings.ToLower(c.Get("Nick", "bot")) botnick := strings.ToLower(c.Get("Nick", "bot"))
r := fmt.Sprintf(`(?i)\s*\W*\s*?%s\W*$`, botnick)
if suffixRegex == nil {
suffixRegex = regexp.MustCompile(r)
}
if botnick == "" { if botnick == "" {
log.Fatal(). log.Fatal().
Msgf(`You must run catbase -set nick -val <your bot nick>`) Msgf(`You must run catbase -set nick -val <your bot nick>`)
@ -204,9 +200,6 @@ func IsCmd(c *config.Config, message string) (bool, string) {
if message[0] == ':' || message[0] == ',' { if message[0] == ':' || message[0] == ',' {
message = message[1:] message = message[1:]
} }
} else if suffixRegex.MatchString(message) {
iscmd = true
message = suffixRegex.ReplaceAllString(message, "")
} else { } else {
for _, cmdc := range cmdcs { for _, cmdc := range cmdcs {
if strings.HasPrefix(lowerMessage, cmdc) && len(cmdc) > 0 { if strings.HasPrefix(lowerMessage, cmdc) && len(cmdc) > 0 {