Hello universe
This commit is contained in:
commit
3583d74eff
|
@ -0,0 +1,2 @@
|
||||||
|
node_modules
|
||||||
|
.hubot_history
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Wormhole
|
||||||
|
|
||||||
|
Wormhole is a portal (sometimes called a bridge) between XMPP MUC and other
|
||||||
|
chat protocols. It's a very simple script on top of [Hubot][hubot]. In the case
|
||||||
|
of this particular bot, it is bridging IRC channels with XMPP MUC rooms.
|
||||||
|
|
||||||
|
[hubot]: http://hubot.github.com
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
export PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH"
|
||||||
|
|
||||||
|
exec node_modules/.bin/hubot --name "wormhole" "$@"
|
|
@ -0,0 +1,7 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
call npm install
|
||||||
|
SETLOCAL
|
||||||
|
SET PATH=node_modules\.bin;node_modules\hubot\node_modules\.bin;%PATH%
|
||||||
|
|
||||||
|
node_modules\.bin\hubot.cmd --name "wormhole" %*
|
|
@ -0,0 +1,2 @@
|
||||||
|
[
|
||||||
|
]
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "wormhole",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"author": "Sebastian Kippe <sebastian@kip.pe>",
|
||||||
|
"description": "A portal between IRC and XMPP MUC",
|
||||||
|
"dependencies": {
|
||||||
|
"hubot": "^3.3.2",
|
||||||
|
"hubot-irc": "github:67P/hubot-irc#dev",
|
||||||
|
"simple-xmpp": "^1.3.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "10.x"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
#!/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_UNFLOOD="300" \
|
||||||
|
HUBOT_IRC_NICKSERV_USERNAME="wormhole" \
|
||||||
|
HUBOT_IRC_NICKSERV_PASSWORD="" \
|
||||||
|
HUBOT_WORMHOLE_XMPP_JID="wormhole@kosmos.org" \
|
||||||
|
HUBOT_WORMHOLE_XMPP_PASSWORD="" \
|
||||||
|
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" \
|
||||||
|
bin/hubot -a irc --name wormhole
|
|
@ -0,0 +1,51 @@
|
||||||
|
const hubot = require("hubot");
|
||||||
|
const xmpp = require('simple-xmpp');
|
||||||
|
|
||||||
|
const hubotRooms = process.env.HUBOT_IRC_ROOMS.split(',');
|
||||||
|
const xmppRooms = process.env.HUBOT_WORMHOLE_XMPP_ROOMS.split(',');
|
||||||
|
|
||||||
|
module.exports = function (robot) {
|
||||||
|
|
||||||
|
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}`;
|
||||||
|
|
||||||
|
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)
|
||||||
|
});
|
||||||
|
|
||||||
|
xmppRooms.forEach(room => xmpp.join(`${room}/wormhole`));
|
||||||
|
|
||||||
|
function messageMUC(res) {
|
||||||
|
const message = res.message;
|
||||||
|
|
||||||
|
if ((typeof message === 'object' && message.constructor.name === 'TextMessage') ||
|
||||||
|
message instanceof hubot.TextMessage) {
|
||||||
|
if (message.user['id'] === 'botka_dev') return;
|
||||||
|
if (!hubotRooms.includes(message.user.room)) return;
|
||||||
|
|
||||||
|
const room = xmppRooms[hubotRooms.indexOf(message.user.room)];
|
||||||
|
const msg = `[irc] <${message.user['id']}> ${message.text}`;
|
||||||
|
|
||||||
|
xmpp.send(room, msg, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const listener = new hubot.Listener(robot, function() {
|
||||||
|
return true;
|
||||||
|
}, function(res) {
|
||||||
|
return messageMUC(res);
|
||||||
|
});
|
||||||
|
|
||||||
|
robot.listeners.push(listener);
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue