From c2cc4ab85b85d654a3ce9d5c39894b4928651059 Mon Sep 17 00:00:00 2001 From: Flummi Date: Mon, 5 Sep 2016 21:07:15 +0000 Subject: [PATCH] muh --- src/trigger/umode.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/trigger/umode.js b/src/trigger/umode.js index afede59..d01fef1 100644 --- a/src/trigger/umode.js +++ b/src/trigger/umode.js @@ -1,17 +1,18 @@ module.exports = (bot, trigger, lib) => { trigger.add({ name: 'umode', - call: /^\!umode (.*)/i, + call: /^\!umode .*/i, level: 100, active: 1, func: (e) => { var processModes = (modes) => { var delta, modeList = []; + console.log(modes.split('')); if(modes.split('').some((token) => { if(token === '-') {delta = false; return;} if(token === '+') {delta = true; return;} if(token === ' ') return; - if(typeof delta !== "boolean") return true; + if(typeof delta === "undefined") return true; modeList.push({ delta: delta, mode: token @@ -22,8 +23,18 @@ module.exports = (bot, trigger, lib) => { var allowedModes = [ 'q','a','o','h','v' ]; - var modes = processModes(e.message); - console.log(modes); + var tmp = e.message.trim().split(' '); + tmp.shift(); + var user = tmp[tmp.length - 1]; + if(user.match(/(\+|-)/)) + user = e.user.getNick(); + else + tmp.pop(); + e.reply("input: "+JSON.stringify(tmp)); + var modes = processModes(tmp.join(' ')); + e.reply("output: "+JSON.stringify(modes)); + e.reply("user: "+user); + return; var user = modes[modes.length - 1]; if(user.toLowerCase() != bot.me.nick.toLowerCase()) {