irc/plugins/useful/pong.go

20 lines
365 B
Go
Raw Normal View History

2024-05-14 05:58:51 +00:00
package useful
import (
"context"
"tuxpa.in/a/irc/pkg/ircv3"
)
type Pong struct {
}
func (u *Pong) Middleware(next ircv3.Handler) ircv3.Handler {
return ircv3.HandlerFunc(func(ctx context.Context, w ircv3.MessageWriter, m *ircv3.Message) {
if m.Command == "PING" {
w.WriteMessage(ircv3.NewMessage("PONG", m.Param(0)))
}
next.Handle(ctx, w, m)
})
}