add art command

This commit is contained in:
hgw 2023-10-02 02:14:36 +00:00
parent 7092ff4ded
commit 77cb76e48f
8 changed files with 68 additions and 3927 deletions

View File

@ -1,8 +1,12 @@
FROM node:14
FROM node:16
RUN apt update && apt install -y python3 python3-pip wget
RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
RUN mkdir -p /tmp/fascinus && chown -R node:node /tmp/fascinus
WORKDIR /home/node/app
COPY package*.json ./
USER node
COPY --chown=node:node banter/requirements.txt .
RUN pip3 install -r requirements.txt
COPY --chown=node:node package*.json ./
RUN npm i
COPY --chown=node:node . .
CMD [ "node", "bot.js" ]

View File

@ -7,5 +7,10 @@ cold hard bot for cold hard chats
- $flood [AMOUNT] [TEXT] - Floods the channel with a specific line x amount of times
- $ctcpflood [TARGET] [TEXT (one word)] [AMOUNT] - Sends x amount of CTCP requests to a target.
- $sneed - Pastes the Sneed's Feed and Seed copypasta.
- $rspam [LINES] - Spams x lines of random characters
- $uspam [LINES] - Spams x lines of random unicode characters of varying length
- $rspam [LINES] - Spams x lines of random characters.
- $uspam [LINES] - Spams x lines of random unicode characters of varying length.
- $art [IMAGE URL (png/jpg)] - Creates IRC art using a source image.
## Credits
- [phy1729/banter](https://github.com/phy1729/banter) - $art uses a version of banter modified to allow URLs in place of local image files. These changes will be published upstream once refined.

View File

@ -74,7 +74,7 @@ if __name__ == "__main__":
args.file,
float(args.d),
int(args.w),
str(args.t),
args.colorfmt.encode().decode("unicode_escape"),
args.filler.encode().decode("unicode_escape")
args.filler.encode().decode("unicode_escape"),
str(args.t)
)

49
bot.js
View File

@ -1,15 +1,15 @@
var irc = require("irc");
var fs = require("fs");
var request = require('request');
var art = require('ascii-art');
var crypto = require('crypto').webcrypto;
var randomext = require('./random')
var readline = require('readline');
var path = require('path');
var randomext = require('./random');
const { nextTick } = require("process");
var config = { //edit your shit here
server: "irc.supernets.org",
port: 6697,
SSL: true,
channels: ['#dev'],
channels: ['#fascinus'],
botName: "fascinus",
userName: "fascinus",
realName: "Sneed"
@ -46,6 +46,7 @@ async function help(chan) {
bot.say(chan, "$sneed - Pastes the Sneed's Feed and Seed copypasta.")
bot.say(chan, "$rspam [LINES] - Spams x lines of random characters")
bot.say(chan, "$uspam [LINES] - Spams x lines of random unicode characters of varying length")
bot.say(chan, "$art [IMAGE URL (png/jpg)] - Creates IRC art using a source image.")
}
async function flood(chan, arg) {
@ -105,6 +106,42 @@ async function rspam(chan, amt) {
}
}
async function art(chan, url) {
var ext = path.extname(url)
if (ext === ".png") {
var filetype = "png"
} else if (ext === ".jpg") {
var filetype = "jpg"
} else {
bot.say(chan, "Image must be PNG or JPG");
return
}
console.log("Starting Banter")
const spawn = require("child_process").spawn;
const pythonProcess = spawn('python3', ["banter/banter.py", url, "-t", filetype])
pythonProcess.stdout.on('data', (data) => {
console.log(data.toString())
});
await timer(1000);
fs.stat('output.txt', function(err, stat) {
if (err == null) {
console.log('File exists');
const rl = readline.createInterface({
input: fs.createReadStream('output.txt'),
crlfDelay: Infinity,
});
rl.on('line', (line) => {
bot.say(chan, line);
});
} else if (err.code === 'ENOENT') {
bot.say(chan, "Error")
} else {
bot.say(chan, "Error")
}
});
}
bot.addListener('message', function(nick, to, text, from) {
var args = text.split(' ');
if (args[0] === '$help') {
@ -119,6 +156,8 @@ bot.addListener('message', function(nick, to, text, from) {
rspam(to, args[1])
} else if (args[0] === '$uspam') {
uspam(to, args[1]);
} else if (args[0] === '$art') {
art(to, args[1]);
}
});

View File

@ -3,4 +3,6 @@ services:
fascinus:
container_name: fascinus
build: .
restart: always
restart: always
dns:
- 1.1.1.1

0
output.txt Normal file
View File

3915
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,12 +4,8 @@
"description": "",
"main": "index.js",
"dependencies": {
"ascii-art": "^2.8.5",
"crypto": "^1.0.1",
"dotenv": "^16.3.1",
"fs": "^0.0.1-security",
"irc": "^0.5.2",
"request": "^2.88.2"
"irc": "^0.5.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"