aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/server.go b/server.go
index 1868078..e87dad2 100644
--- a/server.go
+++ b/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:], " "))