minor fixes, tagged command errors
This commit is contained in:
parent
1cfa94dc75
commit
2d97e7d3e7
12
util.go
12
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)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user