summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.js3
-rw-r--r--globals.js2
-rw-r--r--handlers.js17
-rw-r--r--index.js68
4 files changed, 22 insertions, 68 deletions
diff --git a/commands.js b/commands.js
index 59be364..138c55f 100644
--- a/commands.js
+++ b/commands.js
@@ -67,10 +67,11 @@ module.exports.joinChannel = function (channel, sendJoin) {
}
module.exports.removeChannel = function(channel, sendPart) {
- var channelObj = client.channel(channel)
+
chanId = $("[data-tab='"+channel+"'].chat").attr("data-id");
$("[data-tab='"+channel+"']").remove();
if (sendPart) {
+ var channelObj = client.channel(channel)
channelObj.part();
}
while ($("[data-id="+(chanId-1)+"]").length == 0 && chanId >=0) {
diff --git a/globals.js b/globals.js
index a0c689b..d96f702 100644
--- a/globals.js
+++ b/globals.js
@@ -3,3 +3,5 @@ module.exports.channels = ['status']
module.exports.pms = []
module.exports.networks = []
+
+module.exports.myNick = ""
diff --git a/handlers.js b/handlers.js
index c6d86de..24b783c 100644
--- a/handlers.js
+++ b/handlers.js
@@ -173,6 +173,23 @@ module.exports.handleCommands = function(myClient) {
chatTab.scrollTop(chatTab.prop("scrollHeight"));
})
+ client.on('kick', function(event) {
+ var kicked = event.kicked
+ var by = event.nick
+ var channel = event.channel
+ var reason = event.message
+ if (globals.myNick == kicked) {
+ commands.removeChannel(channel, false);
+ } else {
+ if($(".ui.users[data-tab='"+channel+"'] [data-nick="+kicked+"]").length > 0) {
+ $(".ui.users[data-tab='"+channel+"'] [data-nick="+kicked+"]").remove();
+ }
+ var chatTab = $("[data-tab='"+ channel +"'].chat");
+ chatTab.append("<p class='chat-line'>"+kicked+" was kicked from "+channel+" by "+by+" ("+reason+")</p>")
+ chatTab.scrollTop(chatTab.prop("scrollHeight"));
+ }
+ })
+
}
function receiveMsg(target, from, message) {
diff --git a/index.js b/index.js
index b4333e5..48f55a0 100644
--- a/index.js
+++ b/index.js
@@ -62,6 +62,7 @@ console.log($("#channel-input").val());
version: "blachat 0.1.3"
});
+ globals.myNick = myNick
commands.init(client)
handlers.setChannels(channels)
handlers.handleCommands(client)
@@ -170,23 +171,6 @@ client.addListener('raw', function(message) {
}
});
-client.addListener('ctcp-version', function(from, to, text, message) {
- client.ctcp(from, "VERSION", "VERSION "+progName + " v"+ version)
-});
-
-client.addListener('quit', function(nick, reason, channels, message) {
- channels.forEach(function(channel) {
- channel = channel.replace("#","")
- if($(".ui.users[data-tab=chan-"+channel+"] [data-nick="+nick+"]").length > 0) {
- $(".ui.users[data-tab=chan-"+channel+"] [data-nick="+nick+"]").remove();
- }
- var chatTab = $("[data-tab=chan-"+ channel +"].chat");
- chatTab.append("<p class='chat-line'>"+nick+" quit ("+reason+")</p>")
- chatTab.scrollTop(chatTab.prop("scrollHeight"));
- });
-
-});
-
client.addListener('kick', function(channel, nick, by, reason, message) {
if (myNick == nick) {
removeChannel(channel, false);
@@ -213,54 +197,4 @@ client.addListener('kill', function(nick, reason, channels, message) {
});
});
-
-client.addListener('+mode', function(channel, by, mode, argument, message) {
- console.log(message)
- channel = channel.replace("#","")
- var chatTab = $("[data-tab=chan-"+ channel +"].chat");
- var modeLine = mode;
- if (mode == "o") {
- modeLine = " gives channel operator status to " + argument;
- } else if (mode == "v") {
- modeLine = " gives voice to " + argument;
- } else if (mode == "h") {
- modeLine = " gives channel half-operator status to " + argument;
- } else if (mode == "q") {
- modeLine = " gives channel owner status to " + argument;
- } else if (argument == myNick) {
- modeLine = " sets mode +" + mode + " on " + argument;
- } else if (argument != null) {
- modeLine = " sets mode " + mode + " " + argument + " on #" +channel;
- } else {
- modeLine = " sets mode +"+mode+" on #" +channel
- }
- var chatTab = $("[data-tab=chan-"+ channel +"].chat");
- chatTab.append("<p class='chat-line'>"+by+modeLine+"</p>");
- chatTab.scrollTop(chatTab.prop("scrollHeight"));
-});
-
-client.addListener('-mode', function(channel, by, mode, argument, message) {
- channel = channel.replace("#","")
- var chatTab = $("[data-tab=chan-"+ channel +"].chat");
- var modeLine = mode;
- if (mode == "o") {
- modeLine = " removes channel operator status from ";
- } else if (mode == "v") {
- modeLine = " removes voice from ";
- } else if (mode == "h") {
- modeLine = " removes channel half-operator status from ";
- } else if (mode == "q") {
- modeLine = " removes channel owner status from ";
- } else if (argument == myNick) {
- modeLine = " sets mode -"+mode+" on " + argument;
- } else if (argument != null) {
- modeLine = " sets mode -" + mode + " " + argument + " on #" +channel;
- } else {
- modeLine = " sets mode -"+mode+" on #" +channel
- }
- var chatTab = $("[data-tab=chan-"+ channel +"].chat");
- chatTab.append("<p class='chat-line'>"+by+modeLine+"</p>");
- chatTab.scrollTop(chatTab.prop("scrollHeight"));
-});
-
}