respond to !ping command

This commit is contained in:
lyx0 2024-01-10 18:32:29 +01:00
parent 9d25b1569c
commit cdef12f1d5
3 changed files with 7 additions and 5 deletions

View file

@ -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":
}
}

View file

@ -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)

View file

@ -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)