this shit now works

This commit is contained in:
hgw 2023-10-02 02:11:24 +00:00
parent 113292f323
commit 1c8b6f84d1
9 changed files with 125 additions and 62 deletions

1
.gitignore vendored
View File

@ -132,4 +132,3 @@ dist
.env .env
scratch scratch
config/default.json config/default.json
commands/godwords.js

View File

@ -1,5 +1,6 @@
FROM node:16 FROM node:16
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app RUN mkdir -p /home/node/app/node_modules \
&& chown -R node:node /home/node/app
WORKDIR /home/node/app WORKDIR /home/node/app
USER node USER node
COPY --chown=node:node package*.json ./ COPY --chown=node:node package*.json ./

View File

@ -2,9 +2,12 @@
RSS Parser for IRC RSS Parser for IRC
This bot is currently in development and not fully functioning. Do not use in production.
## Commands ## Commands
- m!set [OPTION] [VALUE] - Changes a bot setting, more info to be added here later. - `m!feed [FEED] [ENTRIES]` - Return the last x amount of entries from any RSS feed.
- `m!set [OPTION] [VALUE]` - Changes a bot setting, more info to be added here later.
## Deployment ## Deployment

45
bot.js
View File

@ -5,7 +5,7 @@ var readline = require('readline');
const { Worker } = require('worker_threads'); const { Worker } = require('worker_threads');
//var randomWords = require('better-random-words'); //var randomWords = require('better-random-words');
var connconfig = { //edit your shit here var connconfig = {
server: config.get('irc.server'), server: config.get('irc.server'),
port: config.get('irc.port'), port: config.get('irc.port'),
SSL: config.get('irc.port'), SSL: config.get('irc.port'),
@ -34,53 +34,36 @@ async function help(chan, sub) {
} }
if (sub === "default") { if (sub === "default") {
bot.say(chan, 'Mercury - https://git.supernets.org/hogwart7/mercury') bot.say(chan, 'Mercury - https://git.supernets.org/hogwart7/mercury')
bot.say(chan, 'm!l5 [FEED] - Return the last 5 entries in any RSS feed.')
bot.say(chan, "m!set [OPTION] [VALUE] - run r!help set for details") bot.say(chan, "m!set [OPTION] [VALUE] - run r!help set for details")
} }
} }
async function feed(chan, provfeed, n) {
async function rspam(chan, amt) { if (provfeed === undefined) {
var arr = [] bot.say(chan, "No feed has been provided.")
if (amt > 10000) {
bot.say(chan, "no")
} else {
if (amt === undefined) {
var amt = 100
} }
for(var i=0; i < amt; i++){ if (n === undefined) {
var string = generateRandomString(70); var n = 5;
await timer(2);
arr.push(string)
} }
var output = arr.join("\n") const worker = new Worker('./commands/feed.js', {
bot.say(chan, output);
}
}
async function godwords(chan, amt) {
if (amt > 100000) {
bot.say(chan, "no")
} else {
if (amt === undefined) {
var amt = 50
}
const worker = new Worker('./commands/godwords.js', {
workerData: { workerData: {
amt provfeed,
n
} }
}); });
worker.once('message', (string) => { worker.once('message', (string) => {
console.log('Received string from worker, posting.'); console.log('Received output from last5 worker, posting.');
bot.say(chan, string); bot.say(chan, string);
}); });
}
} }
bot.addListener('message', function(nick, to, text, from) { bot.addListener('message', function(nick, to, text, from) {
var args = text.split(' '); var args = text.split(' ');
if (args[0] === 'm!help') { if (args[0] === 'm!help') {
help(to, args[1]); help(to, args[1]);
} else if (args[0] === 'm!feed') {
feed(to, args[1], args[2]);
} }
}); });
@ -88,4 +71,4 @@ bot.addListener('error', function(message) {
console.log('error: ', message); console.log('error: ', message);
}); });
console.log('Starting Fascinus'); console.log('Starting Mercury');

View File

@ -1,16 +0,0 @@
const { parentPort, workerData } = require('worker_threads');
const { amt } = workerData;
var randomWords = require('../lib/randomword');
var output = [];
var string = [];
var text = [];
for(var i=0; i < amt; i++){
var word = randomWords({ exactly: 1 });
text.push(word);
}
var string = text.join(" ")
output.push(string);
parentPort.postMessage(output);
process.exit()

View File

@ -9,5 +9,9 @@
"nickname": "mercury", "nickname": "mercury",
"username": "mercury", "username": "mercury",
"realname": "git.supernets.org/hogwart7/mercury" "realname": "git.supernets.org/hogwart7/mercury"
},
"feed": {
"useragent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 13.4; rv:109.0) Gecko/20100101 Firefox/114.0",
"body_max_chars": "200"
} }
} }

View File

@ -5,5 +5,4 @@ services:
build: . build: .
restart: always restart: always
volumes: volumes:
- './config/default.json:/home/node/app/config/default.json' - './config:/home/node/app/config'
- './config/settings.txt:/home/node/app/config/settings.txt'

90
package-lock.json generated
View File

@ -7,10 +7,13 @@
"": { "": {
"name": "mercury", "name": "mercury",
"version": "1.0.0", "version": "1.0.0",
"license": "ISC",
"dependencies": { "dependencies": {
"config": "^3.3.9", "config": "^3.3.9",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"irc": "^0.5.2" "irc": "^0.5.2",
"rss-parser": "^3.13.0",
"striptags": "^3.2.0"
} }
}, },
"node_modules/config": { "node_modules/config": {
@ -24,6 +27,14 @@
"node": ">= 10.0.0" "node": ">= 10.0.0"
} }
}, },
"node_modules/entities": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz",
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==",
"funding": {
"url": "https://github.com/fb55/entities?sponsor=1"
}
},
"node_modules/fs": { "node_modules/fs": {
"version": "0.0.1-security", "version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
@ -94,6 +105,45 @@
"engines": { "engines": {
"node": ">=0.6" "node": ">=0.6"
} }
},
"node_modules/rss-parser": {
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/rss-parser/-/rss-parser-3.13.0.tgz",
"integrity": "sha512-7jWUBV5yGN3rqMMj7CZufl/291QAhvrrGpDNE4k/02ZchL0npisiYYqULF71jCEKoIiHvK/Q2e6IkDwPziT7+w==",
"dependencies": {
"entities": "^2.0.3",
"xml2js": "^0.5.0"
}
},
"node_modules/sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"node_modules/striptags": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/striptags/-/striptags-3.2.0.tgz",
"integrity": "sha512-g45ZOGzHDMe2bdYMdIvdAfCQkCTDMGBazSw1ypMowwGIee7ZQ5dU0rBJ8Jqgl+jAKIv4dbeE1jscZq9wid1Tkw=="
},
"node_modules/xml2js": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz",
"integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==",
"dependencies": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/xmlbuilder": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==",
"engines": {
"node": ">=4.0"
}
} }
}, },
"dependencies": { "dependencies": {
@ -105,6 +155,11 @@
"json5": "^2.2.3" "json5": "^2.2.3"
} }
}, },
"entities": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz",
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A=="
},
"fs": { "fs": {
"version": "0.0.1-security", "version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
@ -153,6 +208,39 @@
"requires": { "requires": {
"nan": "^2.3.3" "nan": "^2.3.3"
} }
},
"rss-parser": {
"version": "3.13.0",
"resolved": "https://registry.npmjs.org/rss-parser/-/rss-parser-3.13.0.tgz",
"integrity": "sha512-7jWUBV5yGN3rqMMj7CZufl/291QAhvrrGpDNE4k/02ZchL0npisiYYqULF71jCEKoIiHvK/Q2e6IkDwPziT7+w==",
"requires": {
"entities": "^2.0.3",
"xml2js": "^0.5.0"
}
},
"sax": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
},
"striptags": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/striptags/-/striptags-3.2.0.tgz",
"integrity": "sha512-g45ZOGzHDMe2bdYMdIvdAfCQkCTDMGBazSw1ypMowwGIee7ZQ5dU0rBJ8Jqgl+jAKIv4dbeE1jscZq9wid1Tkw=="
},
"xml2js": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.5.0.tgz",
"integrity": "sha512-drPFnkQJik/O+uPKpqSgr22mpuFHqKdbS835iAQrUC73L2F5WkboIRd63ai/2Yg6I1jzifPFKH2NTK+cfglkIA==",
"requires": {
"sax": ">=0.6.0",
"xmlbuilder": "~11.0.0"
}
},
"xmlbuilder": {
"version": "11.0.1",
"resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-11.0.1.tgz",
"integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA=="
} }
} }
} }

View File

@ -6,11 +6,13 @@
"dependencies": { "dependencies": {
"config": "^3.3.9", "config": "^3.3.9",
"fs": "^0.0.1-security", "fs": "^0.0.1-security",
"irc": "^0.5.2" "irc": "^0.5.2",
"rss-parser": "^3.13.0",
"striptags": "^3.2.0"
}, },
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "hogwart7", "author": "hogwart7",
"license": "" "license": "ISC"
} }