This commit is contained in:
parent
9c78ea2d48
commit
7c684af8c3
79 changed files with 3594 additions and 3257 deletions
40
internal/plugin/ping/ping.go
Normal file
40
internal/plugin/ping/ping.go
Normal file
|
@ -0,0 +1,40 @@
|
|||
package ping
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.nakama.town/fmartingr/butterrobot/internal/model"
|
||||
"git.nakama.town/fmartingr/butterrobot/internal/plugin"
|
||||
)
|
||||
|
||||
// PingPlugin is a simple ping/pong plugin
|
||||
type PingPlugin struct {
|
||||
plugin.BasePlugin
|
||||
}
|
||||
|
||||
// New creates a new PingPlugin instance
|
||||
func New() *PingPlugin {
|
||||
return &PingPlugin{
|
||||
BasePlugin: plugin.BasePlugin{
|
||||
ID: "dev.ping",
|
||||
Name: "Ping",
|
||||
Help: "Responds to 'ping' with 'pong'",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// OnMessage handles incoming messages
|
||||
func (p *PingPlugin) OnMessage(msg *model.Message, config map[string]interface{}) []*model.Message {
|
||||
if !strings.EqualFold(strings.TrimSpace(msg.Text), "ping") {
|
||||
return nil
|
||||
}
|
||||
|
||||
response := &model.Message{
|
||||
Text: "pong",
|
||||
Chat: msg.Chat,
|
||||
ReplyTo: msg.ID,
|
||||
Channel: msg.Channel,
|
||||
}
|
||||
|
||||
return []*model.Message{response}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue