From 88cdc57e5455833439774215ceff6ee228f8ccb8 Mon Sep 17 00:00:00 2001 From: Benjamin Bouvier Date: Thu, 23 Jun 2016 21:36:35 +0200 Subject: [PATCH] Initial commit; --- .gitignore | 3 +++ config.example.js | 21 +++++++++++++++++++++ index.js | 30 ++++++++++++++++++++++++++++++ package.json | 16 ++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 .gitignore create mode 100644 config.example.js create mode 100644 index.js create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f6beec --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +npm-debug.log +node_modules/ +config.js diff --git a/config.example.js b/config.example.js new file mode 100644 index 0000000..aa886b9 --- /dev/null +++ b/config.example.js @@ -0,0 +1,21 @@ +module.exports = { + // IRC server to connect to. + server: 'chat.freenode.net', + + // List of channels / people to report to. + channels: ['#horsejs'], + + // IRC nick/names for the bot + nick: 'gitlab-bot', + userName: 'gitlab-bot', + realName: 'gitlab-bot', + + // Secret as entered in the Gitlab Webhook instance. + secret: '12345', + + // Port on which to run. + port: 1337, + + // Network interface on which to run the webhook server. + hostname: '0.0.0.0' +} diff --git a/index.js b/index.js new file mode 100644 index 0000000..73c0236 --- /dev/null +++ b/index.js @@ -0,0 +1,30 @@ +var irc = require('irc'); +var express = require('express'); +var bodyParser = require('body-parser'); + +var config = require('./config'); + +var client = new irc.Client(config.server, config.nick, { + //debug: true, + channels: config.channels, + userName: config.userName, + realName: config.realName, + retryDelay: 120000 +}); + +var say = client.say.bind(client); + +var app = express(); + +app.use(bodyParser.json()); // for parsing application/json +app.use(bodyParser.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded + +app.post('/', function(req, res) { + var body = req.body || {}; + + res.sendStatus(200); +}); + +app.listen(config.port, config.hostname, function() { + console.log('gitlab-to-irc running.'); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..d435409 --- /dev/null +++ b/package.json @@ -0,0 +1,16 @@ +{ + "name": "jshorse", + "version": "1.0.0", + "description": "An irc bot that can read horse_javascript tweets and repeat them.", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Benjamin Bouvier ", + "license": "ISC", + "dependencies": { + "body-parser": "^1.15.2", + "express": "4.14.0", + "irc": "0.3.9" + } +}