initial code; hello world

master
lub 6 years ago
parent c5ce1328c2
commit 776039429f

2
.gitignore vendored

@ -1 +1,3 @@
node_modules
config.yaml
registration.yaml

@ -0,0 +1,11 @@
{
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js",
"args": ["--config","config.yaml"]
}
]
}

@ -0,0 +1,3 @@
homeserver: 'http://localhost:8008'
domain: 'localhost'
registration: 'registration.yaml'

@ -0,0 +1,9 @@
type: object
requires: ['homeserver', 'domain', registration]
properties:
homesever:
type: string
domain:
type: string
registration:
type: string

@ -0,0 +1,45 @@
const appservicePort = 9000;
const roomId = '!MQClELEJFefiUVmsNw:imninja.net';
//const http = require('http');
const Cli = require('matrix-appservice-bridge').Cli;
const Bridge = require('matrix-appservice-bridge').Bridge;
const AppServiceRegistration = require("matrix-appservice-bridge").AppServiceRegistration;
let bridge;
//http.createServer((request, response) => {
// console.log('http online');
//}).listen(appservicePort);
new Cli({
registrationPath: 'registration.yaml',
generateRegistration: (reg, callback) => {
reg.setId(AppServiceRegistration.generateToken());
reg.setHomeserverToken(AppServiceRegistration.generateToken());
reg.setAppServiceToken(AppServiceRegistration.generateToken());
reg.setSenderLocalpart('_rss');
reg.addRegexPattern('users', '@_rss_.*', true);
callback(reg);
},
bridgeConfig: {
schema: 'config.schema.yaml'
},
run: (port, config) => {
bridge = new Bridge({
homeserverUrl: config.homeserver,
domain: config.domain,
registration: config.registration,
controller: {
onUserQuery: (queriedUser) => {
return {};
},
onEvent: (request, context) => {
return;
}
}
});
bridge.run(port, config);
bridge.getIntent('@_rss_test0r:imninja.net').sendText(roomId, 'asef :)');
}
}).run({port: 9000});