From 777808182320e0584a38e2ae9fdfb6e8e7d99973 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sat, 15 Oct 2016 20:59:27 +0100 Subject: Move set topic and join channel functions to commands.js --- handlers.js | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'handlers.js') 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("

Topic for "+channel+" is "+topic+" - set by "+nick+" at "+time+"

") 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(""+channel+""); - $("#chan-container").append("
"); - - var chanTab = $("[data-tab='"+ channel +"'].tab"); - - chanTab.append("
"); - chanTab.append("
"); - chanTab.append("
"); - - $('.menu .item').tab({history:false}); - - numChans++; -} - function receiveMsg(target, from, message) { // message = message.autoLink( { // callback: function(url) { -- cgit v1.2.3