diff options
author | Joe Robinson <joe@grabyo.com> | 2016-10-13 14:26:31 +0100 |
---|---|---|
committer | Joe Robinson <joe@grabyo.com> | 2016-10-13 14:26:31 +0100 |
commit | 97fa9bf68f5e3aa50f094fa7e7bb4c427f2702aa (patch) | |
tree | 502e2a2abd88d0b5487bb8137a854698fea9881d | |
parent | 90533882ae77f811f01cc842fce9cab68df877ba (diff) |
Create user list on channel join, remove some debug lines
-rw-r--r-- | handlers.js | 38 |
1 files 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("<div class=item data-nick="+nick+">"+mode+nick+"</div>") } - } + }) }); } 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("<div class=item data-nick="+nick+">"+nick+"</div>") - } - } - }) numChans++; } |