Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
Basti | 59d82f3a0b | |
Râu Cao | 46eb0452f5 | |
Basti | 33747dd59d | |
Basti | 82313c72ea | |
Basti | d653d184f2 | |
Basti | 377040e196 | |
Basti | aacfc7f83d |
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wormhole",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wormhole",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"private": true,
|
||||
"author": "Sebastian Kippe <sebastian@kip.pe>",
|
||||
"description": "A portal between IRC and XMPP MUC",
|
||||
|
|
11
run.sh
11
run.sh
|
@ -1,14 +1,15 @@
|
|||
#!/bin/bash
|
||||
HUBOT_LOG_LEVEL="debug" \
|
||||
HUBOT_IRC_SERVER="irc.freenode.net" \
|
||||
HUBOT_IRC_ROOMS="#kosmos-random,#kosmos-dev" \
|
||||
HUBOT_IRC_NICK="wormhole" \
|
||||
HUBOT_IRC_ROOMS="#kosmos-random" \
|
||||
HUBOT_IRC_NICK="wormholedev" \
|
||||
HUBOT_IRC_UNFLOOD="300" \
|
||||
HUBOT_IRC_NICKSERV_USERNAME="wormhole" \
|
||||
HUBOT_IRC_NICKSERV_USERNAME="wormholedev" \
|
||||
HUBOT_IRC_NICKSERV_PASSWORD="" \
|
||||
HUBOT_WORMHOLE_XMPP_JID="wormhole@kosmos.org" \
|
||||
HUBOT_WORMHOLE_XMPP_JID="jimmy@kosmos.org" \
|
||||
HUBOT_WORMHOLE_XMPP_PASSWORD="" \
|
||||
HUBOT_WORMHOLE_XMPP_NICKNAME="wormhole" \
|
||||
HUBOT_WORMHOLE_XMPP_HOST="xmpp.kosmos.org" \
|
||||
HUBOT_WORMHOLE_XMPP_PORT="5222" \
|
||||
HUBOT_WORMHOLE_XMPP_ROOMS="kosmos-random@chat.kosmos.org,kosmos-dev@chat.kosmos.org" \
|
||||
HUBOT_WORMHOLE_XMPP_ROOMS="kosmos-random@kosmos.chat" \
|
||||
bin/hubot -a irc --name wormhole
|
||||
|
|
|
@ -3,27 +3,44 @@ const xmpp = require('simple-xmpp');
|
|||
|
||||
const hubotRooms = process.env.HUBOT_IRC_ROOMS.split(',');
|
||||
const xmppRooms = process.env.HUBOT_WORMHOLE_XMPP_ROOMS.split(',');
|
||||
const xmppNickname = process.env.HUBOT_WORMHOLE_XMPP_NICKNAME;
|
||||
|
||||
const xmppConfig = {
|
||||
jid: process.env.HUBOT_WORMHOLE_XMPP_JID,
|
||||
password: process.env.HUBOT_WORMHOLE_XMPP_PASSWORD,
|
||||
host: process.env.HUBOT_WORMHOLE_XMPP_HOST,
|
||||
port: parseInt(process.env.HUBOT_WORMHOLE_XMPP_PORT)
|
||||
};
|
||||
|
||||
module.exports = function (robot) {
|
||||
|
||||
xmpp.on('online', function(data) {
|
||||
robot.logger.info('XMPP connected with JID: ' + data.jid.toString());
|
||||
|
||||
xmppRooms.forEach(room => xmpp.join(`${room}/${xmppNickname}`));
|
||||
});
|
||||
|
||||
xmpp.on('close', function() {
|
||||
robot.logger.info('XMPP connection has been closed. Re-connecting...');
|
||||
|
||||
xmpp.connect(xmppConfig);
|
||||
});
|
||||
|
||||
xmpp.on('groupchat', function(conference, from, message, whatevs, meta) {
|
||||
if (meta || (from === 'wormhole')) return;
|
||||
if (!xmppRooms.includes(conference)) return;
|
||||
|
||||
const room = hubotRooms[xmppRooms.indexOf(conference)];
|
||||
const msg = `[xmpp] <${from}> ${message}`;
|
||||
const msg = `<${from}> ${message}`;
|
||||
|
||||
robot.messageRoom(room, msg);
|
||||
});
|
||||
|
||||
xmpp.connect({
|
||||
jid: process.env.HUBOT_WORMHOLE_XMPP_JID,
|
||||
password: process.env.HUBOT_WORMHOLE_XMPP_PASSWORD,
|
||||
host: process.env.HUBOT_WORMHOLE_XMPP_HOST,
|
||||
port: parseInt(process.env.HUBOT_WORMHOLE_XMPP_PORT)
|
||||
xmpp.on('error', function(err) {
|
||||
robot.logger.error(err);
|
||||
});
|
||||
|
||||
xmppRooms.forEach(room => xmpp.join(`${room}/wormhole`));
|
||||
xmpp.connect(xmppConfig);
|
||||
|
||||
function messageMUC(res) {
|
||||
const message = res.message;
|
||||
|
@ -34,7 +51,7 @@ module.exports = function (robot) {
|
|||
if (!hubotRooms.includes(message.user.room)) return;
|
||||
|
||||
const room = xmppRooms[hubotRooms.indexOf(message.user.room)];
|
||||
const msg = `[irc] <${message.user['id']}> ${message.text}`;
|
||||
const msg = `<${message.user['id']}> ${message.text}`;
|
||||
|
||||
xmpp.send(room, msg, true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue