From a6930add23657c0a894103e3d4da1df905717188 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 22 Mar 2017 03:07:59 +0100 Subject: [PATCH 1/5] muh --- src/trigger/f0ckrand.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/trigger/f0ckrand.js b/src/trigger/f0ckrand.js index 25e6c3f..147bdad 100644 --- a/src/trigger/f0ckrand.js +++ b/src/trigger/f0ckrand.js @@ -26,7 +26,8 @@ module.exports = (lib) => { let where = params.in.concat(params.not); let query = `SELECT id, username FROM f0ck.items ${where.length > 0 ? `WHERE ${where.join(' || ')}` : ''} ORDER BY rand() LIMIT 1`; - console.log( query ); + e.reply( query ); + e.reply( JSON.stringify( vars ) ); lib.sql.query(query, vars, (err, rows) => { e.reply(!err && rows.length > 0 ? `f0ckrnd: ${lib.cfg.main.url}/${rows[0].id} by: ${rows[0].username}` : 'nothing found, f0cker'); }); From b6e9b9c40d6a5f663a54c4b757672fde236daba2 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 22 Mar 2017 13:58:23 +0100 Subject: [PATCH 2/5] muh --- src/trigger/f0ckrand.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/trigger/f0ckrand.js b/src/trigger/f0ckrand.js index 147bdad..dfa0324 100644 --- a/src/trigger/f0ckrand.js +++ b/src/trigger/f0ckrand.js @@ -7,24 +7,23 @@ module.exports = (lib) => { func: (e) => { let args = lib.sql.escape(e.message).trim().split(" ").slice(2); let params = { - "in": [], - "not": [] + inc: [], + exc: [] }; for(let i = 0; i < args.length; i++) { let name = args[0]; if(name.charAt(0) === "!") - params.not.push(name.slice(1)); + params.exc.push(name.slice(1)); else - params.in.push(name); + params.inc.push(name); } - let vars = params.in.concat(params.not); - - params.in = new Array(params.in.length).fill('username LIKE ?'); - params.not = params.in.length > 0 ? [] : new Array(params.not.length).fill('username NOT LIKE ?'); - let where = params.in.concat(params.not); - let query = `SELECT id, username FROM f0ck.items ${where.length > 0 ? `WHERE ${where.join(' || ')}` : ''} ORDER BY rand() LIMIT 1`; + 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 FROM f0ck.items ${where.length > 0 ? `WHERE ${where}` : ''} ORDER BY rand() LIMIT 1`; e.reply( query ); e.reply( JSON.stringify( vars ) ); From a22b82ccbdf77c50c93352f1bcc05a1147165474 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 22 Mar 2017 14:01:26 +0100 Subject: [PATCH 3/5] muh --- src/trigger/f0ckrand.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/trigger/f0ckrand.js b/src/trigger/f0ckrand.js index dfa0324..2d12616 100644 --- a/src/trigger/f0ckrand.js +++ b/src/trigger/f0ckrand.js @@ -11,6 +11,10 @@ module.exports = (lib) => { exc: [] }; + e.reply( JSON.stringify( args ) ); + e.reply( JSON.stringify( params ) ); + + for(let i = 0; i < args.length; i++) { let name = args[0]; if(name.charAt(0) === "!") From 7d2ffcd60ec059cc95ea5608bc27392bb0944869 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 22 Mar 2017 14:03:10 +0100 Subject: [PATCH 4/5] muh --- src/trigger/f0ckrand.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/trigger/f0ckrand.js b/src/trigger/f0ckrand.js index 2d12616..21358e3 100644 --- a/src/trigger/f0ckrand.js +++ b/src/trigger/f0ckrand.js @@ -5,7 +5,7 @@ module.exports = (lib) => { level: 0, active: 1, func: (e) => { - let args = lib.sql.escape(e.message).trim().split(" ").slice(2); + let args = e.message.trim().split(" ").slice(2); let params = { inc: [], exc: [] From 39d5b3965818ad18017b704d3111139de05418ff Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 22 Mar 2017 14:06:09 +0100 Subject: [PATCH 5/5] muh --- src/trigger/f0ckrand.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/trigger/f0ckrand.js b/src/trigger/f0ckrand.js index 21358e3..764d972 100644 --- a/src/trigger/f0ckrand.js +++ b/src/trigger/f0ckrand.js @@ -10,11 +10,7 @@ module.exports = (lib) => { inc: [], exc: [] }; - - e.reply( JSON.stringify( args ) ); - e.reply( JSON.stringify( params ) ); - - + for(let i = 0; i < args.length; i++) { let name = args[0]; if(name.charAt(0) === "!") @@ -29,8 +25,6 @@ module.exports = (lib) => { let where = params.inc.concat(params.exc).join(' || '); let query = `SELECT id, username FROM f0ck.items ${where.length > 0 ? `WHERE ${where}` : ''} ORDER BY rand() LIMIT 1`; - e.reply( query ); - e.reply( JSON.stringify( vars ) ); lib.sql.query(query, vars, (err, rows) => { e.reply(!err && rows.length > 0 ? `f0ckrnd: ${lib.cfg.main.url}/${rows[0].id} by: ${rows[0].username}` : 'nothing found, f0cker'); });