+groan.
This commit is contained in:
parent
c0e6b28c58
commit
608646deb1
@ -10,6 +10,7 @@
|
||||
|BotSnack|`(?i)botsnack`|Consumes a botsnack. This pleases mcchunkie and brings balance to the universe.|
|
||||
|Covid|`(?i)^covid: (.+)$`|Queries [thebigboard.cc](http://www.thebigboard.cc)'s api for information on COVID-19.|
|
||||
|Feder|`(?i)^(?:feder: |tayshame: )(.*)$`|check the Matrix federation status of a given URL.|
|
||||
|Groan|`(?i)^@groan$`|Ugh.|
|
||||
|Ham|`(?i)^ham: (\w+)$`|queries the FCC's [ULS](https://wireless2.fcc.gov/UlsApp/UlsSearch/searchLicense.jsp) for a given callsign.|
|
||||
|HighFive|`o/|\\o`|Everyone loves highfives.|
|
||||
|Hi|`(?i)^hi|hi$`|Friendly bots say hi.|
|
||||
|
56
plugins/groan.go
Normal file
56
plugins/groan.go
Normal file
@ -0,0 +1,56 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"github.com/matrix-org/gomatrix"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Groan responds to groans.
|
||||
type Groan struct {
|
||||
}
|
||||
|
||||
// Descr describes this plugin
|
||||
func (h *Groan) Descr() string {
|
||||
return "Ugh."
|
||||
}
|
||||
|
||||
// Re are the regexes that high five uses
|
||||
func (h *Groan) Re() string {
|
||||
return `(?i)^@groan$`
|
||||
}
|
||||
|
||||
// SetStore we don't need a store here.
|
||||
func (h *Groan) SetStore(_ PluginStore) {}
|
||||
|
||||
// Match determines if we should bother groaning
|
||||
func (h *Groan) Match(user, msg string) bool {
|
||||
re := regexp.MustCompile(h.Re())
|
||||
return re.MatchString(msg)
|
||||
}
|
||||
|
||||
func (h *Groan) resp() string {
|
||||
a := []string{
|
||||
"Ugh.",
|
||||
"ugh",
|
||||
"ffffuuuu",
|
||||
"sigh.",
|
||||
"oh fml.",
|
||||
"........",
|
||||
}
|
||||
|
||||
rand.Seed(time.Now().Unix())
|
||||
return a[rand.Intn(len(a))]
|
||||
|
||||
}
|
||||
|
||||
// RespondText to groan events
|
||||
func (h *Groan) RespondText(c *gomatrix.Client, ev *gomatrix.Event, _, post string) error {
|
||||
return SendText(c, ev.RoomID, h.resp())
|
||||
}
|
||||
|
||||
// Name returns the name of the Groan plugin
|
||||
func (h *Groan) Name() string {
|
||||
return "Groan"
|
||||
}
|
@ -217,6 +217,7 @@ var Plugs = Plugins{
|
||||
&BotSnack{},
|
||||
&Covid{},
|
||||
&Feder{},
|
||||
&Groan{},
|
||||
&Ham{},
|
||||
&HighFive{},
|
||||
&Hi{},
|
||||
|
Loading…
Reference in New Issue
Block a user