diff options
-rw-r--r-- | appservice/server.go | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/appservice/server.go b/appservice/server.go index d96f27c..669559d 100644 --- a/appservice/server.go +++ b/appservice/server.go @@ -204,7 +204,7 @@ func handleSystemMessage(mxid string, msg string) { ezbrSystemSend(mxid, "- list: list accounts") ezbrSystemSend(mxid, "- accounts: list accounts") ezbrSystemSend(mxid, "- join <protocol or account> <room id>: join public chat room") - ezbrSystemSend(mxid, "- query <protocol or account> <user id>: open private buffer to contact") + ezbrSystemSend(mxid, "- talk <protocol or account> <user id>: open private conversation to contact") case "list", "account", "accounts": one := false if accts, ok := registeredAccounts[mxid]; ok { @@ -217,15 +217,7 @@ func handleSystemMessage(mxid string, msg string) { ezbrSystemSendf(mxid, "No account currently configured") } case "join": - var account *Account - if accts, ok := registeredAccounts[mxid]; ok { - for name, acct := range accts { - if name == cmd[1] || acct.Protocol == cmd[1] { - account = acct - break - } - } - } + account := findAccount(mxid, cmd[1]) if account != nil { err := account.Conn.Join(connector.RoomID(cmd[2])) if err != nil { @@ -234,16 +226,8 @@ func handleSystemMessage(mxid string, msg string) { } else { ezbrSystemSendf(mxid, "No account with name or using protocol %s", cmd[1]) } - case "query": - var account *Account - if accts, ok := registeredAccounts[mxid]; ok { - for name, acct := range accts { - if name == cmd[1] || acct.Protocol == cmd[1] { - account = acct - break - } - } - } + case "talk": + account := findAccount(mxid, cmd[1]) if account != nil { quser := connector.UserID(cmd[2]) err := account.Conn.Invite(quser, connector.RoomID("")) @@ -268,3 +252,14 @@ func handleSystemMessage(mxid string, msg string) { ezbrSystemSend(mxid, "Unrecognized command. Type `help` if you need some help!") } } + +func findAccount(mxid string, q string) *Account { + if accts, ok := registeredAccounts[mxid]; ok { + for name, acct := range accts { + if name == q || acct.Protocol == q { + return acct + } + } + } + return nil +} |