diff options
author | Joe Robinson <joe@lc8n.com> | 2016-10-15 20:59:27 +0100 |
---|---|---|
committer | Joe Robinson <joe@lc8n.com> | 2016-10-15 20:59:27 +0100 |
commit | 777808182320e0584a38e2ae9fdfb6e8e7d99973 (patch) | |
tree | c78e33ffc2eb333d8fb0eb33312e98387de7dbb1 /handlers.js | |
parent | 855db48bbba753508d68b7d91ec858855e003c9c (diff) |
Move set topic and join channel functions to commands.js
Diffstat (limited to 'handlers.js')
-rw-r--r-- | handlers.js | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/handlers.js b/handlers.js index 0e27c25..9b956c3 100644 --- a/handlers.js +++ b/handlers.js @@ -1,6 +1,7 @@ var linkify = require("linkifyjs"); var linkifyHtml = require('linkifyjs/html'); var util = require("./util.js") +var commands = require("./commands.js") var numChans = 1; var channels; @@ -13,7 +14,7 @@ module.exports.handleCommands = function(myClient) { client = myClient; client.on('registered', function(event) { channels.forEach(function(channelStr) { - joinChannel(channelStr, true); + commands.joinChannel(channelStr, true); }); }); client.on('message', function(event) { @@ -23,7 +24,7 @@ module.exports.handleCommands = function(myClient) { client.on('userlist', function(event) { channel = event.channel if($(".ui.tab[data-tab='"+channel+"']").length == 0) { - joinChannel(channel, false) + commands.joinChannel(channel, false) } event.users.forEach(function (user) { var nick = user.nick @@ -51,7 +52,7 @@ module.exports.handleCommands = function(myClient) { time = "vov" var chatTab = $("[data-tab='"+ channel +"'].chat"); if($(".ui.tab[data-tab='"+channel+"']").length == 0) { - joinChannel(channel, false) + commands.joinChannel(channel, false) } chatTab.append("<p class='chat-line'>Topic for "+channel+" is "+topic+" - set by "+nick+" at "+time+"</p>") var topicTab = $("[data-tab='"+ channel +"'].topic"); @@ -60,31 +61,6 @@ module.exports.handleCommands = function(myClient) { } -function joinChannel(channel, sendJoin) { - - var channelObj = client.channel(channel); - if (sendJoin) { - channelObj.join(); - channelObj.say("beep"); - } - chanId = $(".active.chat").attr("data-id") - - $(".active").removeClass("active"); - - $(".ui.menu").append("<a class='active item' data-id='"+numChans+"' data-tab='"+channel+"'>"+channel+"</a>"); - $("#chan-container").append("<div class='ui active tab' data-id='"+numChans+"' data-tab='"+channel+"'></div>"); - - var chanTab = $("[data-tab='"+ channel +"'].tab"); - - chanTab.append("<div class='ui selection list users' data-id='"+numChans+"' data-tab='"+channel+"'></div>"); - chanTab.append("<div class='ui segment chat' data-id='"+numChans+"' data-tab='"+channel+"'></div>"); - chanTab.append("<div class='ui topic' data-id='"+numChans+"' data-tab='"+channel+"'></div>"); - - $('.menu .item').tab({history:false}); - - numChans++; -} - function receiveMsg(target, from, message) { // message = message.autoLink( { // callback: function(url) { |