From 2d97e7d3e7f20d0ac75194c83150d33aefb5bbdd Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 17 Jul 2022 17:38:17 -0400 Subject: [PATCH] minor fixes, tagged command errors --- util.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/util.go b/util.go index 32423c0..0a3553f 100644 --- a/util.go +++ b/util.go @@ -3,12 +3,20 @@ package matrixbotlib import ( "errors" "fmt" + "log" "strings" "maunium.net/go/mautrix" "maunium.net/go/mautrix/event" ) +var ( + //ErrCmdParseNoPrefix means no prefix was found + ErrCmdParseNoPrefix = errors.New("no prefix found") + //ErrCmdParseNoCmd means no actual commands were found + ErrCmdParseNoCmd = errors.New("nothing to parse from command") +) + //ParseCommand takes a Event and pulls a command + args if available func ParseCommand(evt *event.Event, prefix string) ([]string, error) { body := evt.Content.AsMessage().Body @@ -30,9 +38,9 @@ func AcceptAllRoomInvites(client *mautrix.Client) { if evt.Content.AsMember().Membership.IsInviteOrJoin() { _, err := client.JoinRoomByID(evt.RoomID) if err != nil { - fmt.Printf("error joining room %v", evt.RoomID) + log.Printf("error joining room %v\n", evt.RoomID) } else { - fmt.Printf("joined room %v", evt.RoomID) + log.Printf("joined room %v\n", evt.RoomID) } } })