This commit is contained in:
a 2024-05-14 00:58:51 -05:00
parent 2aa412afee
commit 694e03ae13
Signed by: a
GPG Key ID: 374BC539FE795AF0
5 changed files with 24 additions and 2 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
.env .env
.idea

View File

@ -7,12 +7,13 @@ import (
"os" "os"
"time" "time"
"tuxpa.in/a/irc/plugins/caps/ircmw"
_ "github.com/joho/godotenv/autoload" _ "github.com/joho/godotenv/autoload"
"github.com/lmittmann/tint" "github.com/lmittmann/tint"
"go.uber.org/fx" "go.uber.org/fx"
"go.uber.org/fx/fxevent" "go.uber.org/fx/fxevent"
"tuxpa.in/a/irc/pkg/ircconn" "tuxpa.in/a/irc/pkg/ircconn"
"tuxpa.in/a/irc/pkg/ircmw"
"tuxpa.in/a/irc/pkg/ircv3" "tuxpa.in/a/irc/pkg/ircv3"
"tuxpa.in/a/irc/plugins/auth" "tuxpa.in/a/irc/plugins/auth"
"tuxpa.in/a/irc/plugins/useful" "tuxpa.in/a/irc/plugins/useful"
@ -49,6 +50,7 @@ func exec(log *slog.Logger) error {
(&auth.User{Username: "lain", Realname: "lain a", Hostname: "wired", Server: "wired"}).Middleware, (&auth.User{Username: "lain", Realname: "lain a", Hostname: "wired", Server: "wired"}).Middleware,
ircmw.CapabilityServerTime, ircmw.CapabilityServerTime,
(&useful.Autojoin{Channels: []string{"#lainmaxxing"}}).Middleware, (&useful.Autojoin{Channels: []string{"#lainmaxxing"}}).Middleware,
(&useful.Pong{}).Middleware,
).Handler(ircv3.HandlerFunc(func(ctx context.Context, w ircv3.MessageWriter, m *ircv3.Message) { ).Handler(ircv3.HandlerFunc(func(ctx context.Context, w ircv3.MessageWriter, m *ircv3.Message) {
})) }))

View File

@ -3,8 +3,8 @@ package auth
import ( import (
"context" "context"
"encoding/base64" "encoding/base64"
"tuxpa.in/a/irc/plugins/caps/ircmw"
"tuxpa.in/a/irc/pkg/ircmw"
"tuxpa.in/a/irc/pkg/ircv3" "tuxpa.in/a/irc/pkg/ircv3"
) )

19
plugins/useful/pong.go Normal file
View File

@ -0,0 +1,19 @@
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)
})
}