Browse Source

Import latest version

Bernhard Fröhlich 4 years ago
commit
9a30b24dbc
3 changed files with 85 additions and 0 deletions
  1. 6
    0
      README.md
  2. 35
    0
      package.json
  3. 44
    0
      server.js

+ 6
- 0
README.md View File

@@ -0,0 +1,6 @@
1
+## redportsircbot
2
+
3
+IRC relay bot for buildlogs with an HTTP interface.
4
+
5
+Beware this needs node.js and was running on openshift before they went commercial.
6
+

+ 35
- 0
package.json View File

@@ -0,0 +1,35 @@
1
+{
2
+  "name": "redportsircbot",
3
+  "version": "1.0.1",
4
+  "description": "redports.org IRC Bot for Buildlogs",
5
+  "keywords": [
6
+    "OpenShift",
7
+    "Node.js",
8
+    "application",
9
+    "openshift"
10
+  ],
11
+  "author": {
12
+    "name": "decke",
13
+    "email": "decke@bluelife.at",
14
+    "url": "http://www.redports.org/"
15
+  },
16
+  "homepage": "http://www.redports.org/",
17
+  "repository": {
18
+    "type": "git",
19
+    "url": "https://github.com/openshift/origin-server"
20
+  },
21
+  "engines": {
22
+    "node": ">= 0.6.0",
23
+    "npm": ">= 1.0.0"
24
+  },
25
+  "dependencies": {
26
+    "cloud-env": "^0.1.0",
27
+    "express": "~4.12.3",
28
+    "http": "0.0.0",
29
+    "irc": "~0.3.11"
30
+  },
31
+  "devDependencies": {},
32
+  "bundleDependencies": [],
33
+  "private": true,
34
+  "main": "server.js"
35
+}

+ 44
- 0
server.js View File

@@ -0,0 +1,44 @@
1
+#!/bin/env node
2
+
3
+var token = "YOUR-SECRET-TOKEN-HERE";
4
+
5
+var channels = ["#redports-buildlog"];
6
+
7
+var ipaddr = process.env.NODEJS_IP || "127.0.0.1";
8
+var port = process.env.NODEJS_PORT || 8080;
9
+
10
+var irc = require("irc");
11
+var http = require("http");
12
+var url = require("url");
13
+
14
+var bot = new irc.Client(
15
+	"irc.freenode.net",
16
+	"redports",
17
+	{
18
+		channels: channels,
19
+		port: 8001,
20
+		debug: true,
21
+		showErrors: true,
22
+		floodProtection: true
23
+	}
24
+);
25
+
26
+var server = http.createServer(function (request, response) {
27
+	if(url.parse(request.url, true).query.token && url.parse(request.url, true).query.msg) {
28
+		if(url.parse(request.url, true).query.token == token) {
29
+			console.log("Sending: %s", url.parse(request.url, true).query.msg);
30
+			bot.say(channels[0], url.parse(request.url, true).query.msg);
31
+		}
32
+		else {
33
+			console.log("Invalid token");
34
+		}
35
+	}
36
+
37
+	response.writeHead(200, {"Content-Type": "text/plain"});
38
+	response.end(".");
39
+});
40
+
41
+server.listen(port, ipaddr);
42
+
43
+console.log("Listening on %s:%d ...", ipaddr, port);
44
+

Loading…
Cancel
Save