Bring back the CSI plugin

This commit is contained in:
Aaron Bieber 2023-03-09 13:22:33 -07:00
parent 50661c1d28
commit d996e84c86
No known key found for this signature in database
2 changed files with 56 additions and 0 deletions

View File

@ -309,4 +309,5 @@ var Plugs = Plugins{
&Version{}, &Version{},
&Wb{}, &Wb{},
&Weather{}, &Weather{},
&Yeah{},
} }

55
plugins/yeah.go Normal file
View File

@ -0,0 +1,55 @@
package plugins
import (
"regexp"
"time"
"github.com/matrix-org/gomatrix"
)
// Yeah puts on the shades
type Yeah struct {
}
// Descr describes this plugin
func (h *Yeah) Descr() string {
return "Now you're cool."
}
// Re are the regexes that high five uses
func (h *Yeah) Re() string {
return `(?i)CSI$`
}
// SetStore we don't need a store here.
func (h *Yeah) SetStore(_ PluginStore) {}
// Match determines if we should bother giving a high five
func (h *Yeah) Match(user, msg string) bool {
re := regexp.MustCompile(h.Re())
return ToMe(user, msg) && re.MatchString(msg)
}
func (h *Yeah) Process(from, post string) string {
return ""
}
// RespondText to high five events
func (h *Yeah) RespondText(c *gomatrix.Client, ev *gomatrix.Event, _, post string) error {
parts := []string{
"( •_•)",
"( •_•)>⌐■-■",
"(⌐■_■)",
}
for _, p := range parts {
SendText(c, ev.RoomID, p)
time.Sleep(1 * time.Second)
}
time.Sleep(5 * time.Second)
return SendText(c, ev.RoomID, "YEEEAAAAAAHHHHHH!")
}
// Name returns the name of the Yeah plugin
func (h *Yeah) Name() string {
return "Yeah"
}