From cdef12f1d57f6c19d5d49eaf2b6535395657bec5 Mon Sep 17 00:00:00 2001 From: lyx0 <66651385+lyx0@users.noreply.github.com> Date: Wed, 10 Jan 2024 18:32:29 +0100 Subject: [PATCH] respond to !ping command --- cmd/{nourybot => bot}/commands.go | 4 +++- cmd/{nourybot => bot}/events.go | 2 +- cmd/{nourybot => bot}/main.go | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) rename cmd/{nourybot => bot}/commands.go (92%) rename cmd/{nourybot => bot}/events.go (79%) rename cmd/{nourybot => bot}/main.go (97%) diff --git a/cmd/nourybot/commands.go b/cmd/bot/commands.go similarity index 92% rename from cmd/nourybot/commands.go rename to cmd/bot/commands.go index b85da68..c254114 100644 --- a/cmd/nourybot/commands.go +++ b/cmd/bot/commands.go @@ -6,7 +6,7 @@ import ( "maunium.net/go/mautrix/event" ) -func (app *Application) ParseCommand(evt *event.Event) { +func (app *application) ParseCommand(evt *event.Event) { // commandName is the actual name of the command without the prefix. // e.g. `!ping` would be `ping`. //commandName := strings.ToLower(strings.SplitN(evt.Content.AsMessage().Body, " ", 2)[0][1:]) @@ -27,5 +27,7 @@ func (app *Application) ParseCommand(evt *event.Event) { case "!xd": app.SendText(evt, "xd !") return + + case "!yaf": } } diff --git a/cmd/nourybot/events.go b/cmd/bot/events.go similarity index 79% rename from cmd/nourybot/events.go rename to cmd/bot/events.go index a8f053c..8a419fc 100644 --- a/cmd/nourybot/events.go +++ b/cmd/bot/events.go @@ -2,7 +2,7 @@ package main import "maunium.net/go/mautrix/event" -func (app *Application) ParseEvent(evt *event.Event) { +func (app *application) ParseEvent(evt *event.Event) { // TODO: // Log the events or whatever, I don't even know what events there all are rn. app.Log.Info().Msgf("Event: %s", evt.Content.AsMessage().Body) diff --git a/cmd/nourybot/main.go b/cmd/bot/main.go similarity index 97% rename from cmd/nourybot/main.go rename to cmd/bot/main.go index 190ef52..52dc2a1 100644 --- a/cmd/nourybot/main.go +++ b/cmd/bot/main.go @@ -32,7 +32,7 @@ var debug = flag.Bool("debug", false, "Enable debug logs") //var database = flag.String("database", "test.db", "SQLite database path") -type Application struct { +type application struct { MatrixClient *mautrix.Client Log zerolog.Logger } @@ -68,7 +68,7 @@ func main() { } client.Log = log - app := &Application{ + app := &application{ MatrixClient: client, Log: log, } @@ -174,7 +174,7 @@ func main() { } } -func (app Application) SendText(evt *event.Event, message string) { +func (app *application) SendText(evt *event.Event, message string) { room := evt.RoomID resp, err := app.MatrixClient.SendText(context.TODO(), room, message)