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