Skip to content

Instantly share code, notes, and snippets.

@kfatehi
Forked from AndrewJDR/matrix-run-as-puppet.js
Created January 2, 2017 00:09
Show Gist options
  • Save kfatehi/e0d56d3a391349299d37ff47ae69ec4e to your computer and use it in GitHub Desktop.
Save kfatehi/e0d56d3a391349299d37ff47ae69ec4e to your computer and use it in GitHub Desktop.
const fs = require('fs');
const {
Puppet
} = require("matrix-puppet-bridge");
const puppet = new Puppet('/Users/ajohnson/matrixwork/rls/matrix-appservice-imessage/config.json');
puppet.startClient().then(()=>{
const client = puppet.getClient();
var obj = JSON.parse(fs.readFileSync(process.argv[2]))
var desiredRoomAlias = obj.key.replace(/^@/, '#__mpb__');
var roomId = obj.value.room_id;
console.log(roomId, desiredRoomAlias);
return client.createAlias(desiredRoomAlias, roomId).then(() => {
return client.stopClient();
});
}).catch((err)=> {
console.log(err.message);
process.exit(1);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment