diff --git a/package.json b/package.json index 068bd8a..dd8e14f 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,14 @@ "description": "f0ck, kennste?", "main": "index.mjs", "scripts": { - "start": "node --experimental-json-modules --harmony-optional-chaining src/index.mjs", - "trigger": "node --experimental-json-modules --harmony-optional-chaining debug/trigger.mjs" + "start": "node --experimental-json-modules src/index.mjs", + "trigger": "node --experimental-json-modules debug/trigger.mjs" }, "author": "Flummi", "license": "MIT", "dependencies": { "cuffeo": "^1.0.6-1", - "flumm-fetch-cookies": "^1.3.5", - "mariadb": "^2.3.1" + "flumm-fetch-cookies": "^1.4.0", + "mariadb": "^2.4.2" } } diff --git a/public/b/.empty b/public/b/.empty old mode 100644 new mode 100755 diff --git a/src/inc/trigger/f0ckrand.mjs b/src/inc/trigger/f0ckrand.mjs index cc35e58..deb9bc3 100644 --- a/src/inc/trigger/f0ckrand.mjs +++ b/src/inc/trigger/f0ckrand.mjs @@ -23,11 +23,11 @@ export default async bot => { params.inc.push(name); } - let vars = params.inc.concat(params.inc.length == 0 ? params.exc : []); + let vars = params.inc.concat(params.inc.length === 0 ? params.exc : []); params.inc = new Array(params.inc.length).fill("username like ?"); params.exc = new Array(params.inc.length == 0 ? params.exc.length : 0).fill("username not like ?"); - let where = params.inc.concat(params.exc).join(" || "); - let query = `select id, username, mime, size from items ${where.length > 0 ? `where ${where}` : ""} order by rand() limit 1`; + const where = params.inc.concat(params.exc).join(" || "); + const query = `select id, username, mime, size from items ${where.length > 0 ? `where ${where}` : ""} order by rand() limit 1`; const rows = await sql.query(query, vars); if(rows.length === 0) diff --git a/src/inc/trigger/parser.mjs b/src/inc/trigger/parser.mjs index 02f3ba3..925b53e 100644 --- a/src/inc/trigger/parser.mjs +++ b/src/inc/trigger/parser.mjs @@ -9,10 +9,6 @@ const exec = promisify(_exec); const regex = /https?:\/\/[\w\S(\.|:|/)]+/gi; -console.log( - lib.calcSpeed(123456, 56432) -); - export default async bot => { return [{ @@ -27,8 +23,14 @@ export default async bot => { }); if(links.length === 0) return false; + + if(e.message.match(/(!|-)ignore/)) + return false; - e.reply(`parsing ${links.length} link${links.length > 1 ? "s" : ""}...`); + if(!e.channel.includes("f0ck") && !e.message.match(/(!|-)f0ck/i)) + return false; + + //e.reply(`parsing ${links.length} link${links.length > 1 ? "s" : ""}...`); links.forEach(async link => { // check repost (link) @@ -44,6 +46,8 @@ export default async bot => { const filename = `${uuid}.${meta.ext}`; + e.reply(`downloading ${filename}...`); + // download data const start = new Date(); const source = (await exec(`youtube-dl "${link}" --max-filesize 10000m -o ./tmp/${filename}`)).stdout.trim(); @@ -70,7 +74,7 @@ export default async bot => { const insertq = await sql.query( "insert into items (src, dest, mime, size, checksum, username, userchannel, usernetwork, stamp, active) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", - [ link, filename, mime, size, checksum, e.user.username, e.channel, e.network, ~~(new Date() / 1000), 1 ] + [ link, filename, mime, size, checksum, e.user.nick || e.user.username, e.channel, e.network, ~~(new Date() / 1000), 1 ] ); // generate thumbnail @@ -88,8 +92,7 @@ export default async bot => { e.reply([ `title: ${meta.fulltitle}`, - `size: ${lib.formatSize(size)}`, - `speed: ${lib.calcSpeed(size, end)} (ytdl: ${end})`, + `size: ${lib.formatSize(size)} ${lib.calcSpeed(size, end)} (ytdl: ${end})`, `link: ${cfg.main.url}/${insertq.insertId}` ]);