aboutsummaryrefslogtreecommitdiff
path: root/server.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-03-09 17:41:53 +0100
committerAlex Auvolat <alex@adnab.me>2020-03-09 17:41:53 +0100
commitf9e0c58f3c0e90b987b7763f020ea5dcbf366779 (patch)
treeda02fdd4d02ec2631736757e3fc2cf8dbbd3e2d5 /server.go
parent0d6fa02a782a5679716a0244098697af756d0699 (diff)
downloadeasybridge-f9e0c58f3c0e90b987b7763f020ea5dcbf366779.tar.gz
easybridge-f9e0c58f3c0e90b987b7763f020ea5dcbf366779.zip
Fix revUserId (messenger) and implement search (messenger only for now)
Diffstat (limited to 'server.go')
-rw-r--r--server.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/server.go b/server.go
index 294ad7f..84b1893 100644
--- a/server.go
+++ b/server.go
@@ -228,6 +228,7 @@ func handleSystemMessage(mxid string, msg string) {
ezbrSystemSend(mxid, "- accounts: list accounts")
ezbrSystemSend(mxid, "- join <protocol or account> <room id>: join public chat room")
ezbrSystemSend(mxid, "- talk <protocol or account> <user id>: open private conversation to contact")
+ ezbrSystemSend(mxid, "- search <protocol or account> <name>: search for users by name")
case "list", "account", "accounts":
one := false
if accts, ok := registeredAccounts[mxid]; ok {
@@ -271,6 +272,21 @@ func handleSystemMessage(mxid string, msg string) {
} else {
ezbrSystemSendf(mxid, "No account with name or using protocol %s", cmd[1])
}
+ case "search":
+ account := findAccount(mxid, cmd[1])
+ if account != nil {
+ rep, err := account.Conn.SearchForUsers(cmd[2])
+ if err != nil {
+ ezbrSystemSendf(mxid, "Search error: %s", err)
+ } else {
+ ezbrSystemSendf(mxid, "%d users found", len(rep))
+ for i, user := range rep {
+ ezbrSystemSendf(mxid, "- %s (%s)", i+1, user.DisplayName, user.ID)
+ }
+ }
+ } else {
+ ezbrSystemSendf(mxid, "No account with name or using protocol %s", cmd[1])
+ }
default:
ezbrSystemSend(mxid, "Unrecognized command. Type `help` if you need some help!")
}