22 lines
421 B
Go
22 lines
421 B
Go
|
package useful
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"strings"
|
||
|
|
||
|
"tuxpa.in/a/irc/pkg/ircv3"
|
||
|
)
|
||
|
|
||
|
type Autojoin struct {
|
||
|
Channels []string
|
||
|
}
|
||
|
|
||
|
func (u *Autojoin) Middleware(next ircv3.Handler) ircv3.Handler {
|
||
|
return ircv3.HandlerFunc(func(ctx context.Context, w ircv3.MessageWriter, m *ircv3.Message) {
|
||
|
if m.Command == "005" {
|
||
|
w.WriteMessage(ircv3.NewMessage("JOIN", strings.Join(u.Channels, ",")))
|
||
|
}
|
||
|
next.Handle(ctx, w, m)
|
||
|
})
|
||
|
}
|