From 97fa9bf68f5e3aa50f094fa7e7bb4c427f2702aa Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 13 Oct 2016 14:26:31 +0100 Subject: Create user list on channel join, remove some debug lines --- handlers.js | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/handlers.js b/handlers.js index b2437bc..938c2e2 100644 --- a/handlers.js +++ b/handlers.js @@ -21,32 +21,42 @@ module.exports.handleCommands = function(myClient) { }); }); client.on('message', function(event) { - console.log("messsagee + " + event.message) console.log(event); receiveMsg(event.target, event.nick, event.message) }) + client.on('userlist', function(event) { - console.log(event); channel = event.channel.replace("#","") - console.log(channel); + if($(".ui.tab[data-tab=chan-"+channel+"]").length == 0) { - console.log("there"); joinChannel(channel, false) } - for(nick in event.nicks) { - var mode = nicks[nick]; + event.users.forEach(function (user) { + var nick = user.nick + var mode = "" + user.modes.forEach(function (modeChar) { + if (modeChar === "o") { + mode = "@" + console.log(mode) + } else if (modeChar === "h") { + mode = "%" + } else if (modeChar === "v") { + mode = "+" + } + }) if($(".ui.users[data-tab=chan-"+channel+"] [data-nick="+nick+"]").length == 0) { $(".ui.users[data-tab=chan-"+channel+"]").append("
"+mode+nick+"
") } - } + }) }); } function joinChannel(channel, sendJoin) { console.log("here"); - if (sendJoin) { + var channelObj = client.channel(channel); + if (sendJoin) { buffers.push(channelObj); channelObj.join(); channelObj.say("beep"); @@ -67,18 +77,6 @@ function joinChannel(channel, sendJoin) { $('.menu .item').tab({history:false}); - channelObj.updateUserList(function() { - channel = event.channel.replace("#","") - console.log(channel); - if($(".ui.tab[data-tab=chan-"+channel+"]").length == 0) { - console.log("there"); - } - for(nick in channelObj.users) { - if($(".ui.users[data-tab=chan-"+channel+"] [data-nick="+nick+"]").length == 0) { - $(".ui.users[data-tab=chan-"+channel+"]").append("
"+nick+"
") - } - } - }) numChans++; } -- cgit v1.2.3