Created
October 27, 2015 20:39
-
-
Save ara4n/7ea48e6068d787a04f96 to your computer and use it in GitHub Desktop.
Example of how to read a state event of a room (in this instance, the topic of #matrix:matrix.org)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sdk = require("matrix-js-sdk"); | |
var myUserId = "@matthew:matrix.org"; | |
var myAccessToken = "s3cr3t"; | |
var matrixClient = sdk.createClient({ | |
baseUrl: "https://matrix.org", | |
accessToken: myAccessToken, | |
userId: myUserId | |
}); | |
matrixClient.on("syncComplete", function() { | |
var room = matrixClient.getRoom('!cURbafjkfsMDVwdRDQ:matrix.org'); | |
var state = room.currentState; | |
var topic = state.getStateEvents('m.room.topic')[0]; | |
console.log(topic.getContent().topic); | |
}, function(e) { | |
console.error(e); | |
}); | |
matrixClient.startClient(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment