mirror of
https://github.com/lyx0/nourybot-matrix.git
synced 2024-11-13 19:49:54 +01:00
respond to !ping command
This commit is contained in:
parent
9d25b1569c
commit
cdef12f1d5
3 changed files with 7 additions and 5 deletions
|
@ -6,7 +6,7 @@ import (
|
||||||
"maunium.net/go/mautrix/event"
|
"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.
|
// commandName is the actual name of the command without the prefix.
|
||||||
// e.g. `!ping` would be `ping`.
|
// e.g. `!ping` would be `ping`.
|
||||||
//commandName := strings.ToLower(strings.SplitN(evt.Content.AsMessage().Body, " ", 2)[0][1:])
|
//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":
|
case "!xd":
|
||||||
app.SendText(evt, "xd !")
|
app.SendText(evt, "xd !")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
case "!yaf":
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,7 @@ package main
|
||||||
|
|
||||||
import "maunium.net/go/mautrix/event"
|
import "maunium.net/go/mautrix/event"
|
||||||
|
|
||||||
func (app *Application) ParseEvent(evt *event.Event) {
|
func (app *application) ParseEvent(evt *event.Event) {
|
||||||
// TODO:
|
// TODO:
|
||||||
// Log the events or whatever, I don't even know what events there all are rn.
|
// 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)
|
app.Log.Info().Msgf("Event: %s", evt.Content.AsMessage().Body)
|
|
@ -32,7 +32,7 @@ var debug = flag.Bool("debug", false, "Enable debug logs")
|
||||||
|
|
||||||
//var database = flag.String("database", "test.db", "SQLite database path")
|
//var database = flag.String("database", "test.db", "SQLite database path")
|
||||||
|
|
||||||
type Application struct {
|
type application struct {
|
||||||
MatrixClient *mautrix.Client
|
MatrixClient *mautrix.Client
|
||||||
Log zerolog.Logger
|
Log zerolog.Logger
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ func main() {
|
||||||
}
|
}
|
||||||
client.Log = log
|
client.Log = log
|
||||||
|
|
||||||
app := &Application{
|
app := &application{
|
||||||
MatrixClient: client,
|
MatrixClient: client,
|
||||||
Log: log,
|
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
|
room := evt.RoomID
|
||||||
|
|
||||||
resp, err := app.MatrixClient.SendText(context.TODO(), room, message)
|
resp, err := app.MatrixClient.SendText(context.TODO(), room, message)
|
Loading…
Reference in a new issue