mirror of https://github.com/velour/catbase.git
Compare commits
No commits in common. "21d4b11df9a7272caf2940e50341c8a70513343c" and "d99ee283704d3b963a64690190650a5d4ee171f5" have entirely different histories.
21d4b11df9
...
d99ee28370
10
bot/bot.go
10
bot/bot.go
|
@ -7,7 +7,6 @@ import (
|
|||
"math/rand"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -143,16 +142,10 @@ func (b *bot) Who(channel string) []user.User {
|
|||
return users
|
||||
}
|
||||
|
||||
var suffixRegex *regexp.Regexp
|
||||
|
||||
// IsCmd checks if message is a command and returns its curtailed version
|
||||
func IsCmd(c *config.Config, message string) (bool, string) {
|
||||
cmdcs := c.GetArray("CommandChar", []string{"!"})
|
||||
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 == "" {
|
||||
log.Fatal().
|
||||
Msgf(`You must run catbase -set nick -val <your bot nick>`)
|
||||
|
@ -171,9 +164,6 @@ func IsCmd(c *config.Config, message string) (bool, string) {
|
|||
if message[0] == ':' || message[0] == ',' {
|
||||
message = message[1:]
|
||||
}
|
||||
} else if suffixRegex.MatchString(message) {
|
||||
iscmd = true
|
||||
message = suffixRegex.ReplaceAllString(message, "")
|
||||
} else {
|
||||
for _, cmdc := range cmdcs {
|
||||
if strings.HasPrefix(lowerMessage, cmdc) && len(cmdc) > 0 {
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -67,11 +66,6 @@ func (p *AdminPlugin) message(conn bot.Connector, k bot.Kind, message msg.Messag
|
|||
return false
|
||||
}
|
||||
|
||||
if strings.ToLower(body) == "reboot" {
|
||||
log.Info().Msgf("Got reboot command")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
if strings.ToLower(body) == "shut up" {
|
||||
dur := time.Duration(p.cfg.GetInt("quietDuration", 5)) * time.Minute
|
||||
log.Info().Msgf("Going to sleep for %v, %v", dur, time.Now().Add(dur))
|
||||
|
|
|
@ -39,7 +39,7 @@ func New(b bot.Bot) *EmojifyMePlugin {
|
|||
var emoji []Emoji
|
||||
err = json.Unmarshal(body, &emoji)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msg("Error parsing emoji list")
|
||||
log.Fatal().Err(err).Msg("Error parsing emoji list")
|
||||
}
|
||||
|
||||
emojiMap := map[string]string{}
|
||||
|
|
Loading…
Reference in New Issue