Created
March 14, 2014 14:39
-
-
Save ErikAndreas/9548991 to your computer and use it in GitHub Desktop.
Draft to git(lab?) webhooks forwarding to xmpp (ejabberd2) muc with node.js
This file contains 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 Client = require('node-xmpp-client'), | |
ltx = require('ltx'), | |
express = require('express'), | |
app = express(); | |
room_jid = '[email protected]', | |
room_nick = 'GIT'; | |
// valid user on im server (im.domain.com) | |
var client = new Client({ | |
jid: '[email protected]', | |
password: 'password' | |
}); | |
client.addListener('online', function(data) { | |
console.log('online ' + data.jid.user + '@' + data.jid.domain + '/' + data.jid.resource); | |
stanza = new ltx.Element('presence', { to: room_jid +'/' + room_nick}).c('x', { xmlns: 'http://jabber.org/protocol/muc' }); | |
client.send(stanza); | |
}); | |
// expand this to accept webhooks | |
app.get('/xmpp/:msg', function (req, res) { | |
var msg = req.params.msg; | |
console.log(msg); | |
var stanza = new ltx.Element('message',{ to: room_jid, type: 'groupchat'}).c('body').t(msg); | |
client.send(stanza); | |
res.end('sent'); | |
}); | |
app.listen(3000); | |
console.info('Listening on port 3000'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment