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 (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"maunium.net/go/mautrix"
|
"maunium.net/go/mautrix"
|
||||||
"maunium.net/go/mautrix/event"
|
"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
|
//ParseCommand takes a Event and pulls a command + args if available
|
||||||
func ParseCommand(evt *event.Event, prefix string) ([]string, error) {
|
func ParseCommand(evt *event.Event, prefix string) ([]string, error) {
|
||||||
body := evt.Content.AsMessage().Body
|
body := evt.Content.AsMessage().Body
|
||||||
@ -30,9 +38,9 @@ func AcceptAllRoomInvites(client *mautrix.Client) {
|
|||||||
if evt.Content.AsMember().Membership.IsInviteOrJoin() {
|
if evt.Content.AsMember().Membership.IsInviteOrJoin() {
|
||||||
_, err := client.JoinRoomByID(evt.RoomID)
|
_, err := client.JoinRoomByID(evt.RoomID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("error joining room %v", evt.RoomID)
|
log.Printf("error joining room %v\n", evt.RoomID)
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("joined room %v", evt.RoomID)
|
log.Printf("joined room %v\n", evt.RoomID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user