Skip to content

Instantly share code, notes, and snippets.

@xurizaemon
Last active October 22, 2020 00:46
Show Gist options
  • Save xurizaemon/63fe0d6f64f645943f2a8aac0e4cf5c0 to your computer and use it in GitHub Desktop.
Save xurizaemon/63fe0d6f64f645943f2a8aac0e4cf5c0 to your computer and use it in GitHub Desktop.
matrix client test
// 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