summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--handlers.js38
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++;
}