diff --git a/core/function.go b/core/function.go index 44b5cb0..bbcd53b 100644 --- a/core/function.go +++ b/core/function.go @@ -170,6 +170,33 @@ func handleMessage(sender Sender) { } goon: } + reply.Foreach(func(k, v []byte) error { + if string(v) == "" { + return nil + } + reg, err := regexp.Compile(string(k)) + if err == nil { + if reg.FindString(sender.GetContent()) != "" { + sender.Reply(string(v)) + } + } + return nil + }) + + recall := sillyGirl.Get("recall") + if recall != "" { + for _, v := range strings.Split(recall, "&") { + reg, err := regexp.Compile(v) + if err == nil { + if reg.FindString(sender.GetContent()) != "" { + if sender.IsAdmin() { + sender.Delete() + } + } + } + } + } + } func FetchCookieValue(ps ...string) string { diff --git a/core/recall.go b/core/recall.go deleted file mode 100644 index 05de0ce..0000000 --- a/core/recall.go +++ /dev/null @@ -1,26 +0,0 @@ -package core - -import "strings" - -func init() { - go func() { - recall := sillyGirl.Get("recall") - if recall != "" { - rules := []string{} - for _, v := range strings.Split(recall, "&") { - rules = append(rules, "raw "+v) - } - AddCommand("", []Function{ - { - Rules: rules, - Handle: func(s Sender) interface{} { - if !s.IsAdmin() { - s.Delete() - } - return nil - }, - }, - }) - } - }() -} diff --git a/core/reply.go b/core/reply.go index 2a37e84..5cc2a6f 100644 --- a/core/reply.go +++ b/core/reply.go @@ -13,6 +13,8 @@ import ( "github.com/buger/jsonparser" ) +var reply = NewBucket("reply") + type Reply struct { Rules []string Type string //text url