Fix out of bounds error in user commands (the most stupid bug possible)
This commit is contained in:
parent
ad8461491b
commit
4d909fffd8
1 changed files with 19 additions and 0 deletions
19
server.go
19
server.go
|
@ -225,6 +225,10 @@ func handleTxnEvent(e *mxlib.Event) error {
|
|||
|
||||
func handleSystemMessage(mxid string, msg string) {
|
||||
cmd := strings.Fields(msg)
|
||||
if len(cmd) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
switch cmd[0] {
|
||||
case "help":
|
||||
ezbrSystemSend(mxid, "Welcome to Easybridge! Here is a list of available commands:")
|
||||
|
@ -246,6 +250,11 @@ func handleSystemMessage(mxid string, msg string) {
|
|||
ezbrSystemSendf(mxid, "No account currently configured")
|
||||
}
|
||||
case "join":
|
||||
if len(cmd) != 2 {
|
||||
ezbrSystemSendf(mxid, "Usage: %s <protocol or account> <room id>", cmd[0])
|
||||
return
|
||||
}
|
||||
|
||||
account := findAccount(mxid, cmd[1])
|
||||
if account != nil {
|
||||
err := account.Conn.Join(connector.RoomID(cmd[2]))
|
||||
|
@ -256,6 +265,11 @@ func handleSystemMessage(mxid string, msg string) {
|
|||
ezbrSystemSendf(mxid, "No account with name or using protocol %s", cmd[1])
|
||||
}
|
||||
case "query", "talk":
|
||||
if len(cmd) != 2 {
|
||||
ezbrSystemSendf(mxid, "Usage: %s <protocol or account> <user id>", cmd[0])
|
||||
return
|
||||
}
|
||||
|
||||
account := findAccount(mxid, cmd[1])
|
||||
if account != nil {
|
||||
quser := connector.UserID(cmd[2])
|
||||
|
@ -278,6 +292,11 @@ func handleSystemMessage(mxid string, msg string) {
|
|||
ezbrSystemSendf(mxid, "No account with name or using protocol %s", cmd[1])
|
||||
}
|
||||
case "search":
|
||||
if len(cmd) < 2 {
|
||||
ezbrSystemSendf(mxid, "Usage: %s <protocol or account> <name>", cmd[0])
|
||||
return
|
||||
}
|
||||
|
||||
account := findAccount(mxid, cmd[1])
|
||||
if account != nil {
|
||||
rep, err := account.Conn.SearchForUsers(strings.Join(cmd[2:], " "))
|
||||
|
|
Loading…
Reference in a new issue