Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Question: How can I get information about a room's members? #16

Closed
yveoch opened this issue Jan 5, 2017 · 4 comments
Closed

Question: How can I get information about a room's members? #16

yveoch opened this issue Jan 5, 2017 · 4 comments

Comments

@yveoch
Copy link

yveoch commented Jan 5, 2017

Hi,

I'm trying to build an IOU bot for matrix (https://github.com/dryvenn/matrix-iou-bot) and I was wondering:

  • How do I get a user's "display name" from his ID?

  • How do I get the list of all the users in a room?

The goal here is to map human-friendly names in a message to actual users.

Any help appreciated!

@kegsay
Copy link
Member

kegsay commented Jan 6, 2017

There is no support currently to do this in gomatrix. However, there is an HTTP API you can use which will return the information you want. This is the /joined_members API which is supported on Synapse v0.18.5-rc3 or above. This is a new API which has not yet landed on the specification. Usage:

GET /_matrix/client/r0/rooms/%21ErgjgSgsdWEfw%3Amatrix.org/joined_members HTTP/1.1
Content-Type: application/json

{
  "joined": {
    "@alice:matrix.org": {
        "display_name": "Alice",
        "avatar_url": null
    },
    "@bob:matrix.org": {
        "display_name": "Bob",
        "avatar_url": null
    }
  }
}

Or see https://github.com/matrix-org/matrix-appservice-bridge/blob/master/lib/components/app-service-bot.js#L55 for a JS implementation.

@kegsay
Copy link
Member

kegsay commented Jan 6, 2017

I have added /joined_members to the endpoint checklist bug (#9) - closing this issue.

@kegsay kegsay closed this as completed Jan 6, 2017
@kegsay
Copy link
Member

kegsay commented Jan 6, 2017

Be aware that this API is separate to /sync, so it is racey. If you really care about getting the correct display name for each message for circumstances like:

Alice: test
<Alice changed name to Bob>
Bob: test

then you will need to listen for the membership change events on the DefaultSyncer.

@yveoch
Copy link
Author

yveoch commented Jan 10, 2017

Ok thanks!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants