8
0
Fork 0

Hello universe

Esse commit está contido em:
Basti 2019-07-27 00:03:38 +02:00
commit 3583d74eff
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados
ID da chave GPG: BE4634D632D39B67
9 arquivos alterados com 1173 adições e 0 exclusões

2
.gitignore externo Normal file
Ver arquivo

@ -0,0 +1,2 @@
node_modules
.hubot_history

7
README.md Normal file
Ver arquivo

@ -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

7
bin/hubot Executable file
Ver arquivo

@ -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" "$@"

7
bin/hubot.cmd Normal file
Ver arquivo

@ -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" %*

2
external-scripts.json Normal file
Ver arquivo

@ -0,0 +1,2 @@
[
]

1068
package-lock.json gerado Normal file

Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff

15
package.json Normal file
Ver arquivo

@ -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"
}
}

14
run.sh Executable file
Ver arquivo

@ -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

Ver arquivo

@ -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);
};