Last active
October 22, 2020 00:46
-
-
Save xurizaemon/63fe0d6f64f645943f2a8aac0e4cf5c0 to your computer and use it in GitHub Desktop.
matrix client test
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
// Load dotenv. | |
require('dotenv').config() | |
// Load Matrix SDK. | |
const sdk = require('matrix-js-sdk') | |
const clientConfig = { | |
baseUrl: process.env['HUBOT_MATRIX_HOST'], | |
accessToken: process.env['HUBOT_MATRIX_ACCESS_TOKEN'], | |
userId: process.env['HUBOT_MATRIX_USER'] | |
}; | |
console.log(clientConfig); | |
const client = sdk.createClient(clientConfig); | |
client.startClient(); | |
client.once('sync', function(state, prevState, res) { | |
console.log(state); // state will be 'PREPARED' when the client is ready to use | |
}); | |
client.on("event", function(event){ | |
console.log(event.getType()); | |
// console.log(event); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment