different irc lib and alpine docker base image
This commit is contained in:
parent
0af17631ec
commit
72fae89704
1
.dockerignore
Normal file
1
.dockerignore
Normal file
@ -0,0 +1 @@
|
||||
node_modules
|
@ -1,9 +1,4 @@
|
||||
FROM ubuntu
|
||||
|
||||
RUN apt-get update
|
||||
|
||||
# node stuff
|
||||
RUN apt-get install -y nodejs npm libicu-dev
|
||||
FROM node:alpine
|
||||
|
||||
COPY package.json /data/
|
||||
COPY src /data/src
|
||||
|
105
package-lock.json
generated
105
package-lock.json
generated
@ -63,6 +63,11 @@
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
|
||||
"integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
|
||||
},
|
||||
"core-js": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.2.0.tgz",
|
||||
"integrity": "sha512-gybgLzmr7SQRSF6UzGYXducx4eE10ONQlyEnQoqiGPbmbn7zLkb73tPfc4YbZN0lvcTQwoLNPjq4RuCaCumGyQ=="
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
@ -101,6 +106,11 @@
|
||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
|
||||
},
|
||||
"eventemitter3": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-2.0.3.tgz",
|
||||
"integrity": "sha1-teEHm1n7XhuidxwKmTvgYKWMmbo="
|
||||
},
|
||||
"express": {
|
||||
"version": "4.17.1",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
|
||||
@ -138,6 +148,11 @@
|
||||
"vary": "~1.1.2"
|
||||
}
|
||||
},
|
||||
"fast-text-encoding": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.0.tgz",
|
||||
"integrity": "sha512-R9bHCvweUxxwkDwhjav5vxpFvdPGlVngtqmx4pIZfSUhM/Q4NiIUHB456BAf+Q1Nwu3HEZYONtu+Rya+af4jiQ=="
|
||||
},
|
||||
"finalhandler": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
|
||||
@ -162,6 +177,11 @@
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
|
||||
},
|
||||
"grapheme-splitter": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz",
|
||||
"integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ=="
|
||||
},
|
||||
"http-errors": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
|
||||
@ -174,15 +194,6 @@
|
||||
"toidentifier": "1.0.0"
|
||||
}
|
||||
},
|
||||
"iconv": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv/-/iconv-2.2.3.tgz",
|
||||
"integrity": "sha1-4ITWDut9c9p/CpwJbkyKvgkL+u0=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"nan": "^2.3.5"
|
||||
}
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
@ -201,20 +212,34 @@
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
|
||||
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
|
||||
},
|
||||
"irc": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/irc/-/irc-0.5.2.tgz",
|
||||
"integrity": "sha1-NxT0doNlqW0LL3dryRFmvrJGS7w=",
|
||||
"irc-framework": {
|
||||
"version": "4.4.0",
|
||||
"resolved": "https://registry.npmjs.org/irc-framework/-/irc-framework-4.4.0.tgz",
|
||||
"integrity": "sha512-81ZjeFg0J+OdwGO4S90f8/GpwNwIcP9KaCt0lvRqt1GueT7cKPX2v1yiRML3cJXofkz/MsVZqJCnAEThYYaTUQ==",
|
||||
"requires": {
|
||||
"iconv": "~2.2.1",
|
||||
"irc-colors": "^1.1.0",
|
||||
"node-icu-charset-detector": "~0.2.0"
|
||||
"core-js": "^3.0.1",
|
||||
"eventemitter3": "^2.0.2",
|
||||
"grapheme-splitter": "^1.0.4",
|
||||
"iconv-lite": "^0.4.24",
|
||||
"isomorphic-textencoder": "^1.0.1",
|
||||
"lodash": "^4.17.11",
|
||||
"middleware-handler": "^0.2.0",
|
||||
"regenerator-runtime": "^0.13.2",
|
||||
"socksjs": "^0.5.0"
|
||||
}
|
||||
},
|
||||
"irc-colors": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/irc-colors/-/irc-colors-1.5.0.tgz",
|
||||
"integrity": "sha512-HtszKchBQTcqw1DC09uD7i7vvMayHGM1OCo6AHt5pkgZEyo99ClhHTMJdf+Ezc9ovuNNxcH89QfyclGthjZJOw=="
|
||||
"isomorphic-textencoder": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isomorphic-textencoder/-/isomorphic-textencoder-1.0.1.tgz",
|
||||
"integrity": "sha512-676hESgHullDdHDsj469hr+7t3i/neBKU9J7q1T4RHaWwLAsaQnywC0D1dIUId0YZ+JtVrShzuBk1soo0+GVcQ==",
|
||||
"requires": {
|
||||
"fast-text-encoding": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"lodash": {
|
||||
"version": "4.17.15",
|
||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
|
||||
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
|
||||
},
|
||||
"media-typer": {
|
||||
"version": "0.3.0",
|
||||
@ -231,6 +256,11 @@
|
||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
|
||||
},
|
||||
"middleware-handler": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/middleware-handler/-/middleware-handler-0.2.0.tgz",
|
||||
"integrity": "sha1-vwKvfmtXfAIwYJsq5Y3w5Ebz/QI="
|
||||
},
|
||||
"mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
@ -254,26 +284,11 @@
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
|
||||
},
|
||||
"nan": {
|
||||
"version": "2.14.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
|
||||
"integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==",
|
||||
"optional": true
|
||||
},
|
||||
"negotiator": {
|
||||
"version": "0.6.2",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
|
||||
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
|
||||
},
|
||||
"node-icu-charset-detector": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/node-icu-charset-detector/-/node-icu-charset-detector-0.2.0.tgz",
|
||||
"integrity": "sha1-wjINo3Tdy2cfxUy0oOBB4Vb/1jk=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"nan": "^2.3.3"
|
||||
}
|
||||
},
|
||||
"on-finished": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
|
||||
@ -322,6 +337,11 @@
|
||||
"unpipe": "1.0.0"
|
||||
}
|
||||
},
|
||||
"regenerator-runtime": {
|
||||
"version": "0.13.3",
|
||||
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz",
|
||||
"integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw=="
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
|
||||
@ -375,6 +395,21 @@
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
|
||||
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
|
||||
},
|
||||
"socksjs": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/socksjs/-/socksjs-0.5.0.tgz",
|
||||
"integrity": "sha1-d7AF4y0b/JblYP7dXX7tzxIPh+M=",
|
||||
"requires": {
|
||||
"ipaddr.js": "0.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"ipaddr.js": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-0.1.3.tgz",
|
||||
"integrity": "sha1-J6nKN/FI0hArDvGRzL8sUajwJcY="
|
||||
}
|
||||
}
|
||||
},
|
||||
"statuses": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
|
||||
|
@ -15,6 +15,6 @@
|
||||
"dependencies": {
|
||||
"body-parser": "^1.19.0",
|
||||
"express": "^4.17.1",
|
||||
"irc": "^0.5.2"
|
||||
"irc-framework": "^4.4.0"
|
||||
}
|
||||
}
|
||||
|
28
src/index.js
28
src/index.js
@ -2,7 +2,7 @@ const express = require('express')
|
||||
const bodyParser = require('body-parser')
|
||||
const jsonParser = bodyParser.json()
|
||||
|
||||
const irc = require('irc');
|
||||
const IRC = require('irc-framework');
|
||||
|
||||
const app = express();
|
||||
app.use(express.static('public'));
|
||||
@ -14,22 +14,32 @@ const IRC_CHANNEL = process.env.IRC_CHANNEL
|
||||
const IRC_USERNAME = process.env.IRC_USERNAME
|
||||
const IRC_PASSWORD = process.env.IRC_PASSWORD
|
||||
|
||||
const client = new irc.Client(IRC_HOST, IRC_USERNAME, {
|
||||
channels: ["#" + IRC_CHANNEL],
|
||||
password: IRC_PASSWORD,
|
||||
autoRejoin: true,
|
||||
autoConnect: true,
|
||||
const client = new IRC.Client();
|
||||
client.connect({
|
||||
host: IRC_HOST,
|
||||
port: 6667,
|
||||
nick: IRC_USERNAME,
|
||||
auto_reconnect: true
|
||||
});
|
||||
|
||||
client.addListener('error', function(message) {
|
||||
console.log('error: ', message);
|
||||
var channel;
|
||||
|
||||
client.on('registered', function() {
|
||||
channel = client.channel("#" + IRC_CHANNEL);
|
||||
channel.join();
|
||||
channel.say("beerchat_proxy connected!");
|
||||
});
|
||||
|
||||
// mod -> web
|
||||
app.post('/api/message', jsonParser, function(req, res){
|
||||
|
||||
// req.body = { channel = "", playername = "", message = "" }
|
||||
client.say("#" + IRC_CHANNEL, (req.body.playername ? `<${req.body.playername}> `) + `${req.body.message}`);
|
||||
if (channel) {
|
||||
channel.say(
|
||||
(req.body.playername ? `<${req.body.playername}> ` : "") +
|
||||
req.body.message
|
||||
);
|
||||
}
|
||||
res.end();
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user