From 3b020f95035c925b861fda18808791be3cf775e7 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 22 Mar 2017 01:33:57 +0100 Subject: [PATCH 1/2] in, not in --- src/trigger/f0ckrand.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/trigger/f0ckrand.js b/src/trigger/f0ckrand.js index e9f4107..90f1590 100644 --- a/src/trigger/f0ckrand.js +++ b/src/trigger/f0ckrand.js @@ -6,11 +6,27 @@ module.exports = (lib) => { active: 1, func: (e) => { let args = lib.sql.escape(e.message).split(" ").slice(2); + let params = { + "in": [], + "not": [] + }; + + for(let i = 0; i < args.length; i++) { + params.(args[0].charAt(0) === "!"?not:in).push(args[0]); + } let query = "select `id`,`username` from `f0ck`.`items` "; + //if(args.length > 0) + // query += "where `username` like '" + args.join("' || `username` like '"); + if(args.length > 0) - query += "where `username` like '" + args.join("' || `username` like '"); - query += "order by rand() limit 1"; + query += "where "; + if(params.in.length > 0) + query += "`username` like '" + args.join("' || `username` like '"); + if(params.not.length > 0) + query += "`username` not like '" + args.join("' || `username` not like '"); + + query += " order by rand() limit 1"; console.log( query ); lib.sql.query(query, (err, rows, fields) => { From b182fd2a3f7912aa802417abc0c432d3572689c2 Mon Sep 17 00:00:00 2001 From: Flummi Date: Wed, 22 Mar 2017 01:34:47 +0100 Subject: [PATCH 2/2] ups --- 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 90f1590..9d93d44 100644 --- a/src/trigger/f0ckrand.js +++ b/src/trigger/f0ckrand.js @@ -12,7 +12,7 @@ module.exports = (lib) => { }; for(let i = 0; i < args.length; i++) { - params.(args[0].charAt(0) === "!"?not:in).push(args[0]); + params[(args[0].charAt(0) === "!"?"not":"in")].push(args[0]); } let query = "select `id`,`username` from `f0ck`.`items` ";