From f3d0c81c7b004218665ab1123fb6c8915b190ce0 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Wed, 8 Jun 2016 00:13:12 +0100 Subject: WIP adding irc-framework, debugging --- debugmiddleware.js | 11 +++++++++++ handlers.js | 22 ++++++++++++++++++++++ index.js | 39 ++++++++++++++++++++++++++------------- package.json | 1 + 4 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 debugmiddleware.js create mode 100644 handlers.js diff --git a/debugmiddleware.js b/debugmiddleware.js new file mode 100644 index 0000000..9db3aeb --- /dev/null +++ b/debugmiddleware.js @@ -0,0 +1,11 @@ +module.exports.DebugMiddleware = function() { + return function(client, raw_events, parsed_events) { + parsed_events.use(theMiddleware); + } + + function theMiddleware(command, event, client, next) { + // console.log(command); + // console.log(event); + next(); + } +} diff --git a/handlers.js b/handlers.js new file mode 100644 index 0000000..88259c7 --- /dev/null +++ b/handlers.js @@ -0,0 +1,22 @@ +module.exports.handleCommands = function(client) { + + client.on('registered', function(event) { + console.log(event); + }); + + 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]; + if($(".ui.users[data-tab=chan-"+channel+"] [data-nick="+nick+"]").length == 0) { + $(".ui.users[data-tab=chan-"+channel+"]").append("
"+mode+nick+"
") + } + } + }); +} diff --git a/index.js b/index.js index 96ce9dd..a21b00e 100644 --- a/index.js +++ b/index.js @@ -3,10 +3,15 @@ var linkifyHtml = require('linkifyjs/html'); var shell = require('electron').shell; var config = require('./config.json') var pjson = require('./package.json'); +var handlers = require('./handlers.js'); + +var debugmiddleware = require('./debugmiddleware.js'); const progName = pjson.name; const version = pjson.version; var myNick = config.nick; - +var server = config.server; +var port = config.port; +var password = config.password; $(document).ready(function() { $("#send-message").focus(); }); @@ -17,6 +22,8 @@ $(document).on('click', 'a[href^="http"]', function(event) { }); const irc = require('irc'); +const IRC = require('irc-framework'); +const client = new IRC.Client() $("#server-input").val(config.server); $("#port-input").val(config.port); @@ -31,24 +38,29 @@ config.channels.forEach(function(channel) { txtChannels = txtChannels.substring(0, txtChannels.length-1) $("#channel-input").val(txtChannels); -var client; $('#connect').on('click', function() { console.log($("#channel-input").val()); + server = $("#server-input").val(); + port = $("#port-input").val(); channels = $("#channel-input").val().split(" "); - myNick = $("#nick-input").val() + myNick = $("#nick-input").val(); + password = $("#password-input").val(); ssl = ($("#ssl-input:checked").val() == "on"); console.log(ssl); - client = new irc.Client($("#server-input").val(), myNick, { - channels: channels, - userName: myNick, - password: $("#password-input").val(), - port: $("#port-input").val(), - secure: ssl, - selfSigned: true, - certExpired: true -}); - createListeners(client); + client.use(debugmiddleware.DebugMiddleware()); + client.connect({ + host: server, + port: port, + nick: myNick, + username: myNick, + gecos: myNick, + password: password, + tls: ssl, + rejectUnauthorized: false + }); + + handlers.handleCommands(client); $("#chan-container").show(); @@ -168,6 +180,7 @@ function setTopic(channel, topic) { } function joinChannel(channel, sendJoin) { + console.log("here"); if (sendJoin) { client.join(channel); } diff --git a/package.json b/package.json index d635fce..de2854e 100644 --- a/package.json +++ b/package.json @@ -9,5 +9,6 @@ "semantic-ui": "^2.1.8", "linkifyjs": "2.0.0-beta.9", "irc": "0.5.0", + "irc-framework": "2.0.0", "electron-prebuilt": "0.37.3" } } -- cgit v1.2.3 From 90533882ae77f811f01cc842fce9cab68df877ba Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Wed, 17 Aug 2016 15:13:29 +0100 Subject: Fixed receiving messages --- CHANGELOG | 8 ++--- handlers.js | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- index.js | 48 ++++----------------------- util.js | 31 ++++++++++++++++++ 4 files changed, 146 insertions(+), 48 deletions(-) create mode 100644 util.js diff --git a/CHANGELOG b/CHANGELOG index 66cacb3..553ee76 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -0.1.0 +0.0.1 ----- - Initial alpha release with basic IRC functionality and commands - Support /join and /part of channels @@ -7,13 +7,13 @@ - Can send /whois and channel /list commands - Interpret join, part, quit, kill, kick, and mode messages - Display topics and user lists in channels -0.1.1 +0.0.2 ----- - Added ability to send PMs with /msg -0.2.0 +0.1.0 ----- - Added basic connection UI at startup (automatically populated from config.json) -0.2.1 +0.1.1 ----- - Create channel tab when names list is received, to support bouncers - Added SSL connection option diff --git a/handlers.js b/handlers.js index 88259c7..b2437bc 100644 --- a/handlers.js +++ b/handlers.js @@ -1,9 +1,30 @@ -module.exports.handleCommands = function(client) { +var linkify = require("linkifyjs"); +var linkifyHtml = require('linkifyjs/html'); +var util = require("./util.js") +var numChans = 1; +var channels; +var buffers = []; +var client; +module.exports.setChannels = function(myChannels) { + console.log("setting channels: " + myChannels); + channels = myChannels; +} +module.exports.handleCommands = function(myClient) { + client = myClient; client.on('registered', function(event) { console.log(event); + console.log("channels: " + channels); + channels.forEach(function(channelStr) { + console.log(channelStr); + joinChannel(channelStr, true); + }); }); - + 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("#","") @@ -19,4 +40,86 @@ module.exports.handleCommands = function(client) { } } }); + +} + +function joinChannel(channel, sendJoin) { + console.log("here"); + if (sendJoin) { + var channelObj = client.channel(channel); + buffers.push(channelObj); + channelObj.join(); + channelObj.say("beep"); + } + channel = channel.replace("#",""); + chanId = $(".active.chat").attr("data-id") + + $(".active").removeClass("active"); + + $(".ui.menu").append("#"+channel+""); + $("#chan-container").append("
"); + + var chanTab = $("[data-tab=chan-"+ channel +"].tab"); + + chanTab.append("
"); + chanTab.append("
"); + chanTab.append("
"); + + $('.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("
"+nick+"
") + } + } + }) + numChans++; +} + +function receiveMsg(channel, from, message) { + // message = message.autoLink( { + // callback: function(url) { + // return /\.(gif|png|jpe?g)$/i.test(url) ? '' : null; + // }, + // target: "_blank" + // }); + // console.log(message.autoLink()); + channel = channel.replace("#","") + console.log(from + ' => #'+ channel +': ' + message); + console.log($("[data-tab=chan-"+ channel +"].chat")); + var chatTab = $("[data-tab=chan-"+ channel +"].chat"); + console.log(chatTab); + message = linkifyHtml(message); + console.log(from + ' => #'+ channel +': ' + message); + + chatTab.append("

<" + from + "> " + message +"

"); + var imgMatch = message.match(/[a-z0-9\-]+[\.:]\S+\.(gif|png|jpe?g|bmp)/); + var vidMatch = message.match(/[a-z0-9\-]+[\.:]\S+\.(webm|mp4)/); + var audioMatch = message.match(/[a-z0-9\-]+[\.:]\S+\.(mp3|wav|ogg)/); + var youtubeMatch = message.match(/(https?\:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=)?[a-z0-9A-Z_\-]+/); + if (imgMatch != null && imgMatch.length > 0) { + var image = util.imagify(imgMatch[0],channel); + chatTab.append("

"+image+"

"); + } + if (vidMatch != null && vidMatch.length > 0) { + chatTab.append("

"); + } + if (audioMatch != null && audioMatch.length > 0) { + chatTab.append("

"); + } + if (youtubeMatch != null && youtubeMatch.length > 0) { + console.log(youtubeMatch) + youtubeParts = youtubeMatch[0].split("/"); + youtubeId = youtubeParts[youtubeParts.length-1]; + youtubeId = youtubeId.replace("watch?v=",""); + chatTab.append("

"); + } + + chatTab.scrollTop(chatTab.prop("scrollHeight")); } diff --git a/index.js b/index.js index a21b00e..66c9b41 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,4 @@ -var linkify = require("linkifyjs"); -var linkifyHtml = require('linkifyjs/html'); + var shell = require('electron').shell; var config = require('./config.json') var pjson = require('./package.json'); @@ -49,6 +48,7 @@ console.log($("#channel-input").val()); ssl = ($("#ssl-input:checked").val() == "on"); console.log(ssl); client.use(debugmiddleware.DebugMiddleware()); + console.log(server) client.connect({ host: server, port: port, @@ -57,12 +57,15 @@ console.log($("#channel-input").val()); gecos: myNick, password: password, tls: ssl, - rejectUnauthorized: false + rejectUnauthorized: false, + version: "blachat 0.1.3" }); + handlers.setChannels(channels); handlers.handleCommands(client); + $("#chan-container").show(); $("#message").show(); $("#connect-container").hide(); @@ -200,45 +203,6 @@ function joinChannel(channel, sendJoin) { $('.menu .item').tab({history:false}); - - client.addListener('message#'+channel, function (from, message) { - // message = message.autoLink( { - // callback: function(url) { - // return /\.(gif|png|jpe?g)$/i.test(url) ? '' : null; - // }, - // target: "_blank" - // }); - // console.log(message.autoLink()); - console.log(from + ' => #'+ channel +': ' + message); - var chatTab = $("[data-tab=chan-"+ channel +"].chat"); - message = linkifyHtml(message); - - chatTab.append("

<" + from + "> " + message +"

"); - var imgMatch = message.match(/[a-z0-9\-]+[\.:]\S+\.(gif|png|jpe?g|bmp)/); - var vidMatch = message.match(/[a-z0-9\-]+[\.:]\S+\.(webm|mp4)/); - var audioMatch = message.match(/[a-z0-9\-]+[\.:]\S+\.(mp3|wav|ogg)/); - var youtubeMatch = message.match(/(https?\:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=)?[a-z0-9A-Z_\-]+/); - if (imgMatch != null && imgMatch.length > 0) { - var image = imagify(imgMatch[0],channel); - chatTab.append("

"+image+"

"); - } - if (vidMatch != null && vidMatch.length > 0) { - chatTab.append("

"); - } - if (audioMatch != null && audioMatch.length > 0) { - chatTab.append("

"); - } - if (youtubeMatch != null && youtubeMatch.length > 0) { - console.log(youtubeMatch) - youtubeParts = youtubeMatch[0].split("/"); - youtubeId = youtubeParts[youtubeParts.length-1]; - youtubeId = youtubeId.replace("watch?v=",""); - chatTab.append("

"); - } - - chatTab.scrollTop(chatTab.prop("scrollHeight")); - }); - numChans++; } function removeChannel(channel, sendPart) { diff --git a/util.js b/util.js new file mode 100644 index 0000000..a0bd718 --- /dev/null +++ b/util.js @@ -0,0 +1,31 @@ + +module.exports.imagify = function(url, channel) { + console.log(url); + $.ajax({ + type: 'HEAD', + url: url, + complete: function(xhr) { + var type = xhr.getResponseHeader('Content-Type') + var size = xhr.getResponseHeader('Content-Length'); + console.log(type); + console.log(size); + if (size < 10000000) { + $("[data-img='"+url+"']").append("("+humanize(size)+")"); + $("[data-img='"+url+"']").append("

"); + $("[data-img='"+url+"']").removeClass("loading"); + + } + + } + }); + + return "
"; + +} + +humanize = function(size) { + var units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB']; + var ord = Math.floor(Math.log(size) / Math.log(1000)); + var s = Math.round((size / Math.pow(1000, ord)) * 100) / 100; + return s + ' ' + units[ord]; +} -- cgit v1.2.3 From 97fa9bf68f5e3aa50f094fa7e7bb4c427f2702aa Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 13 Oct 2016 14:26:31 +0100 Subject: Create user list on channel join, remove some debug lines --- handlers.js | 38 ++++++++++++++++++-------------------- 1 file 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("
"+mode+nick+"
") } - } + }) }); } 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("
"+nick+"
") - } - } - }) numChans++; } -- cgit v1.2.3 From 40b1c978b00911cf17dc1a7b45c10b82ce57641d Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 13 Oct 2016 22:34:21 +0100 Subject: Fix PM sending/receiving, some cleanup for messages --- handlers.js | 58 +++++++++++++++++++++++++++++++--------------------------- index.html | 2 +- index.js | 51 ++++++++++++++++++++++----------------------------- main.js | 2 +- 4 files changed, 55 insertions(+), 58 deletions(-) diff --git a/handlers.js b/handlers.js index 938c2e2..e43a250 100644 --- a/handlers.js +++ b/handlers.js @@ -6,29 +6,24 @@ var numChans = 1; var channels; var buffers = []; var client; +var myNick = "" module.exports.setChannels = function(myChannels) { - console.log("setting channels: " + myChannels); channels = myChannels; } module.exports.handleCommands = function(myClient) { client = myClient; client.on('registered', function(event) { - console.log(event); - console.log("channels: " + channels); channels.forEach(function(channelStr) { - console.log(channelStr); joinChannel(channelStr, true); }); }); client.on('message', function(event) { - console.log(event); receiveMsg(event.target, event.nick, event.message) }) client.on('userlist', function(event) { - channel = event.channel.replace("#","") - if($(".ui.tab[data-tab=chan-"+channel+"]").length == 0) { + if($(".ui.tab[data-tab='"+channel+"']").length == 0) { joinChannel(channel, false) } event.users.forEach(function (user) { @@ -37,15 +32,14 @@ module.exports.handleCommands = function(myClient) { 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("
"+mode+nick+"
") + if($(".ui.users[data-tab='"+channel+"'] [data-nick="+nick+"]").length == 0) { + $(".ui.users[data-tab='"+channel+"']").append("
"+mode+nick+"
") } }) }); @@ -53,7 +47,6 @@ module.exports.handleCommands = function(myClient) { } function joinChannel(channel, sendJoin) { - console.log("here"); var channelObj = client.channel(channel); if (sendJoin) { @@ -61,26 +54,25 @@ function joinChannel(channel, sendJoin) { channelObj.join(); channelObj.say("beep"); } - channel = channel.replace("#",""); chanId = $(".active.chat").attr("data-id") $(".active").removeClass("active"); - $(".ui.menu").append("#"+channel+""); - $("#chan-container").append("
"); + $(".ui.menu").append(""+channel+""); + $("#chan-container").append("
"); - var chanTab = $("[data-tab=chan-"+ channel +"].tab"); + var chanTab = $("[data-tab='"+ channel +"'].tab"); - chanTab.append("
"); - chanTab.append("
"); - chanTab.append("
"); + chanTab.append("
"); + chanTab.append("
"); + chanTab.append("
"); $('.menu .item').tab({history:false}); numChans++; } -function receiveMsg(channel, from, message) { +function receiveMsg(target, from, message) { // message = message.autoLink( { // callback: function(url) { // return /\.(gif|png|jpe?g)$/i.test(url) ? '' : null; @@ -88,13 +80,26 @@ function receiveMsg(channel, from, message) { // target: "_blank" // }); // console.log(message.autoLink()); - channel = channel.replace("#","") - console.log(from + ' => #'+ channel +': ' + message); - console.log($("[data-tab=chan-"+ channel +"].chat")); - var chatTab = $("[data-tab=chan-"+ channel +"].chat"); - console.log(chatTab); + + console.log(from + ' => '+ target +': ' + message); + + if (target === client.user.nick) { + target = from + } + var chatTab = $("[data-tab='"+ target +"'].chat"); + + if (chatTab.length == 0) { + $(".ui.menu").append(""+target+""); + $("#chan-container").append("
"); + chanTab = $("[data-tab="+target+"].tab"); + chanTab.append("
"); + + $('.menu .item').tab({history:false}); + numChans++; + chatTab = $("[data-tab="+ target +"].chat"); + } + message = linkifyHtml(message); - console.log(from + ' => #'+ channel +': ' + message); chatTab.append("

<" + from + "> " + message +"

"); var imgMatch = message.match(/[a-z0-9\-]+[\.:]\S+\.(gif|png|jpe?g|bmp)/); @@ -102,7 +107,7 @@ function receiveMsg(channel, from, message) { var audioMatch = message.match(/[a-z0-9\-]+[\.:]\S+\.(mp3|wav|ogg)/); var youtubeMatch = message.match(/(https?\:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/(watch\?v=)?[a-z0-9A-Z_\-]+/); if (imgMatch != null && imgMatch.length > 0) { - var image = util.imagify(imgMatch[0],channel); + var image = util.imagify(imgMatch[0],target); chatTab.append("

"+image+"

"); } if (vidMatch != null && vidMatch.length > 0) { @@ -112,7 +117,6 @@ function receiveMsg(channel, from, message) { chatTab.append("

"); } if (youtubeMatch != null && youtubeMatch.length > 0) { - console.log(youtubeMatch) youtubeParts = youtubeMatch[0].split("/"); youtubeId = youtubeParts[youtubeParts.length-1]; youtubeId = youtubeId.replace("watch?v=",""); diff --git a/index.html b/index.html index 35254dc..7a7951c 100644 --- a/index.html +++ b/index.html @@ -53,7 +53,7 @@ window.$ = window.jQuery = require('./lib/jquery-2.2.2.js'); blachat = require("./index.js"); function scrollToTop(channel) { - var chatTab = $("[data-tab=chan-"+ channel +"].chat"); + var chatTab = $("[data-tab="+ channel +"].chat"); chatTab.scrollTop(chatTab.prop('scrollHeight')); } diff --git a/index.js b/index.js index 66c9b41..1142213 100644 --- a/index.js +++ b/index.js @@ -72,10 +72,6 @@ console.log($("#channel-input").val()); }); - - - - function imagify(url, channel) { console.log(url); $.ajax({ @@ -111,7 +107,7 @@ var numChans = 1; $("#send-message").keypress(function(e) { if(e.which == 13) { var message = $("#send-message").val(); - var channel = $(".tab.active").attr("data-tab").replace("chan-", "#") + var channel = $(".tab.active").attr("data-tab") if (message.indexOf("/join") == 0) { joinChannel(message.substring(6, message.length), true); } else if (message.indexOf("/part") == 0) { @@ -130,7 +126,7 @@ $("#send-message").keypress(function(e) { message = message.substring(6+nick.length, message.length); sendPm(message, nick); } else if (message.indexOf("/topic") == 0) { - var channel = $(".tab.active").attr("data-tab").replace("chan-", "#") + var channel = $(".tab.active").attr("data-tab") topic = message.substring(7, message.length); setTopic(channel, topic); } else if (message.indexOf("/") == 0) { @@ -139,11 +135,11 @@ $("#send-message").keypress(function(e) { client.send("kick", ["#wtest", "wjoe__", "test"]); } else { var tab = $(".tab.active").attr("data-tab"); - if (tab.startsWith("chan-")) { + if (tab.startsWith("#")) { sendMsg(message, channel); - } else if(tab.startsWith("pm-")){ - sendPm(message, tab.substring(3, tab.length)); + } else { + sendPm(message, tab); } } $("#send-message").val(''); @@ -152,26 +148,26 @@ $("#send-message").keypress(function(e) { function sendMsg(message, channel) { client.say(channel, message); - var chanTab = $("[data-tab=chan-"+ channel.replace("#","") +"].chat"); + var chanTab = $("[data-tab='"+ channel +"'].chat"); chanTab.append("

<" + myNick + "> " + message +"

"); chanTab.scrollTop(chanTab.prop("scrollHeight")); } function sendPm(message, nick) { - var chanTab = $("[data-tab=pm-"+nick+"].tab"); + var chanTab = $("[data-tab="+nick+"].tab"); $(".active").removeClass("active"); if (chanTab.length == 0) { - $(".ui.menu").append(""+nick+""); - $("#chan-container").append("
"); - chanTab = $("[data-tab=pm-"+nick+"].tab"); - chanTab.append("
"); + $(".ui.menu").append(""+nick+""); + $("#chan-container").append("
"); + chanTab = $("[data-tab="+nick+"].tab"); + chanTab.append("
"); $('.menu .item').tab({history:false}); numChans++; } - $("[data-tab=pm-"+nick+"]").addClass("active"); - var chatTab = $("[data-tab=pm-"+nick+"].chat"); + $("[data-tab="+nick+"]").addClass("active"); + var chatTab = $("[data-tab="+nick+"].chat"); console.log(nick + ': ' + message); client.say(nick, message); chatTab.append("

<" + myNick + "> " + message +"

"); @@ -183,34 +179,31 @@ function setTopic(channel, topic) { } function joinChannel(channel, sendJoin) { - console.log("here"); if (sendJoin) { client.join(channel); } - channel = channel.replace("#",""); chanId = $(".active.chat").attr("data-id") $(".active").removeClass("active"); - $(".ui.menu").append("#"+channel+""); - $("#chan-container").append("
"); + $(".ui.menu").append(""+channel+""); + $("#chan-container").append("
"); - var chanTab = $("[data-tab=chan-"+ channel +"].tab"); + var chanTab = $("[data-tab="+ channel +"].tab"); - chanTab.append("
"); - chanTab.append("
"); - chanTab.append("
"); + chanTab.append("
"); + chanTab.append("
"); + chanTab.append("
"); $('.menu .item').tab({history:false}); } function removeChannel(channel, sendPart) { - channel = channel.replace("#",""); - chanId = $("[data-tab=chan-"+channel+"].chat").attr("data-id"); - $("[data-tab=chan-"+channel+"]").remove(); + chanId = $("[data-tab="+channel+"].chat").attr("data-id"); + $("[data-tab="+channel+"]").remove(); if (sendPart) { - client.part("#"+channel); + client.part(channel); } while ($("[data-id="+(chanId-1)+"]").length == 0 && chanId >=0) { chanId--; diff --git a/main.js b/main.js index de13265..099b30e 100644 --- a/main.js +++ b/main.js @@ -24,7 +24,7 @@ app.on('window-all-closed', function() { // initialization and is ready to create browser windows. app.on('ready', function() { // Create the browser window. - mainWindow = new BrowserWindow({width: 800, height: 600, title: "blachat"}); + mainWindow = new BrowserWindow({width: 1000, height: 800, title: "blachat"}); // and load the index.html of the app. mainWindow.loadURL('file://' + __dirname + '/index.html'); -- cgit v1.2.3 From eaa8650c9be413664ef52c56b504e9b7fdaafc38 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 13 Oct 2016 23:26:13 +0100 Subject: Temp fix, duplicate channel joining code --- handlers.js | 2 -- index.js | 13 ++++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/handlers.js b/handlers.js index e43a250..6769b53 100644 --- a/handlers.js +++ b/handlers.js @@ -4,7 +4,6 @@ var util = require("./util.js") var numChans = 1; var channels; -var buffers = []; var client; var myNick = "" module.exports.setChannels = function(myChannels) { @@ -50,7 +49,6 @@ function joinChannel(channel, sendJoin) { var channelObj = client.channel(channel); if (sendJoin) { - buffers.push(channelObj); channelObj.join(); channelObj.say("beep"); } diff --git a/index.js b/index.js index 1142213..ca6857d 100644 --- a/index.js +++ b/index.js @@ -114,7 +114,6 @@ $("#send-message").keypress(function(e) { if (message.length > 6) { channel = message.substring(6, message.length); } - console.log() removeChannel(channel, true); } else if (message.indexOf("/whois") == 0) { console.log("whois "+message.substring(7, message.length)); @@ -179,8 +178,11 @@ function setTopic(channel, topic) { } function joinChannel(channel, sendJoin) { + + var channelObj = client.channel(channel); if (sendJoin) { - client.join(channel); + channelObj.join(); + channelObj.say("beep"); } chanId = $(".active.chat").attr("data-id") @@ -189,7 +191,7 @@ function joinChannel(channel, sendJoin) { $(".ui.menu").append(""+channel+""); $("#chan-container").append("
"); - var chanTab = $("[data-tab="+ channel +"].tab"); + var chanTab = $("[data-tab='"+ channel +"'].tab"); chanTab.append("
"); chanTab.append("
"); @@ -197,11 +199,12 @@ function joinChannel(channel, sendJoin) { $('.menu .item').tab({history:false}); + numChans++; } function removeChannel(channel, sendPart) { - chanId = $("[data-tab="+channel+"].chat").attr("data-id"); - $("[data-tab="+channel+"]").remove(); + chanId = $("[data-tab='"+channel+"'].chat").attr("data-id"); + $("[data-tab='"+channel+"']").remove(); if (sendPart) { client.part(channel); } -- cgit v1.2.3 From 4e3b49bd967c9d250922a68e4e7763d977bfb592 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 14 Oct 2016 15:35:43 +0100 Subject: Automatic semantic.js update --- semantic.json | 56 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) mode change 100755 => 100644 semantic.json diff --git a/semantic.json b/semantic.json old mode 100755 new mode 100644 index 41c6498..8f70635 --- a/semantic.json +++ b/semantic.json @@ -16,57 +16,7 @@ "clean": "dist/" }, "permission": false, - "rtl": "No", - "components": [ - "reset", - "site", - "button", - "container", - "divider", - "flag", - "header", - "icon", - "image", - "input", - "label", - "list", - "loader", - "rail", - "reveal", - "segment", - "step", - "breadcrumb", - "form", - "grid", - "menu", - "message", - "table", - "ad", - "card", - "comment", - "feed", - "item", - "statistic", - "accordion", - "checkbox", - "dimmer", - "dropdown", - "embed", - "modal", - "nag", - "popup", - "progress", - "rating", - "search", - "shape", - "sidebar", - "sticky", - "tab", - "transition", - "api", - "form", - "state", - "visibility" - ], - "version": "2.1.8" + "autoInstall": false, + "rtl": false, + "version": "2.2.4" } \ No newline at end of file -- cgit v1.2.3 From 5c188f57835372cd28d6e8fdfd67cc377996cb77 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 14 Oct 2016 15:59:14 +0100 Subject: Automatic semantic.js update --- semantic.json | 56 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) mode change 100755 => 100644 semantic.json diff --git a/semantic.json b/semantic.json old mode 100755 new mode 100644 index 41c6498..8f70635 --- a/semantic.json +++ b/semantic.json @@ -16,57 +16,7 @@ "clean": "dist/" }, "permission": false, - "rtl": "No", - "components": [ - "reset", - "site", - "button", - "container", - "divider", - "flag", - "header", - "icon", - "image", - "input", - "label", - "list", - "loader", - "rail", - "reveal", - "segment", - "step", - "breadcrumb", - "form", - "grid", - "menu", - "message", - "table", - "ad", - "card", - "comment", - "feed", - "item", - "statistic", - "accordion", - "checkbox", - "dimmer", - "dropdown", - "embed", - "modal", - "nag", - "popup", - "progress", - "rating", - "search", - "shape", - "sidebar", - "sticky", - "tab", - "transition", - "api", - "form", - "state", - "visibility" - ], - "version": "2.1.8" + "autoInstall": false, + "rtl": false, + "version": "2.2.4" } \ No newline at end of file -- cgit v1.2.3 From c797f12928e65722beea1265d0383fb10db010f3 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 14 Oct 2016 16:04:27 +0100 Subject: Fix user list --- handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers.js b/handlers.js index 6769b53..0e26d7f 100644 --- a/handlers.js +++ b/handlers.js @@ -21,7 +21,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) } -- cgit v1.2.3 From 855db48bbba753508d68b7d91ec858855e003c9c Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 14 Oct 2016 18:17:34 +0100 Subject: Implement topic function --- handlers.js | 17 ++++++++++++++++- index.js | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/handlers.js b/handlers.js index 0e26d7f..0e27c25 100644 --- a/handlers.js +++ b/handlers.js @@ -41,7 +41,22 @@ module.exports.handleCommands = function(myClient) { $(".ui.users[data-tab='"+channel+"']").append("
"+mode+nick+"
") } }) - }); + }) + + client.on('topic', function(event) { + channel = event.channel + topic = event.topic + //TODO: Handle topicsetby to add the user and time for the topic + nick = "vov" + time = "vov" + var chatTab = $("[data-tab='"+ channel +"'].chat"); + if($(".ui.tab[data-tab='"+channel+"']").length == 0) { + joinChannel(channel, false) + } + chatTab.append("

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

") + var topicTab = $("[data-tab='"+ channel +"'].topic"); + topicTab.html("

"+topic+"

") + }) } diff --git a/index.js b/index.js index ca6857d..7b11a23 100644 --- a/index.js +++ b/index.js @@ -174,7 +174,7 @@ function sendPm(message, nick) { } function setTopic(channel, topic) { - client.send("TOPIC", channel, topic); + client.raw("TOPIC", channel, topic); } function joinChannel(channel, sendJoin) { -- cgit v1.2.3 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 --- commands.js | 34 ++++++++++++++++++++++++++++++++++ handlers.js | 32 ++++---------------------------- index.js | 40 ++++++---------------------------------- 3 files changed, 44 insertions(+), 62 deletions(-) create mode 100644 commands.js diff --git a/commands.js b/commands.js new file mode 100644 index 0000000..b8f53f5 --- /dev/null +++ b/commands.js @@ -0,0 +1,34 @@ +var client + +module.exports.init = function(myClient) { + client = myClient +} + +module.exports.setTopic = function(channel, topic) { + client.raw("TOPIC", channel, topic); +} + +module.exports.joinChannel = function (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++; +} 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) { diff --git a/index.js b/index.js index 7b11a23..d6d0a62 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,7 @@ var shell = require('electron').shell; var config = require('./config.json') var pjson = require('./package.json'); var handlers = require('./handlers.js'); - +var commands = require('./commands.js'); var debugmiddleware = require('./debugmiddleware.js'); const progName = pjson.name; const version = pjson.version; @@ -61,8 +61,9 @@ console.log($("#channel-input").val()); version: "blachat 0.1.3" }); - handlers.setChannels(channels); - handlers.handleCommands(client); + commands.init(client) + handlers.setChannels(channels) + handlers.handleCommands(client) @@ -109,7 +110,7 @@ $("#send-message").keypress(function(e) { var message = $("#send-message").val(); var channel = $(".tab.active").attr("data-tab") if (message.indexOf("/join") == 0) { - joinChannel(message.substring(6, message.length), true); + commands.joinChannel(message.substring(6, message.length), true); } else if (message.indexOf("/part") == 0) { if (message.length > 6) { channel = message.substring(6, message.length); @@ -127,7 +128,7 @@ $("#send-message").keypress(function(e) { } else if (message.indexOf("/topic") == 0) { var channel = $(".tab.active").attr("data-tab") topic = message.substring(7, message.length); - setTopic(channel, topic); + commands.setTopic(channel, topic); } else if (message.indexOf("/") == 0) { command = message.split(" ")[0].replace("/",""); commandArgs = message.replace(command + " ", ""); @@ -173,35 +174,6 @@ function sendPm(message, nick) { chatTab.scrollTop(chanTab.prop("scrollHeight")); } -function setTopic(channel, topic) { - client.raw("TOPIC", channel, topic); -} - -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 removeChannel(channel, sendPart) { chanId = $("[data-tab='"+channel+"'].chat").attr("data-id"); $("[data-tab='"+channel+"']").remove(); -- cgit v1.2.3 From 1dd55949f2d53bf48ca016ab2d4acff172c443b4 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 19:53:23 +0100 Subject: Fix part command, refactoring --- commands.js | 46 ++++++++++++++++++++++++++++++++++++++++++++++ globals.js | 5 +++++ handlers.js | 7 ++++--- index.js | 5 ++++- 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 globals.js diff --git a/commands.js b/commands.js index b8f53f5..6bffb76 100644 --- a/commands.js +++ b/commands.js @@ -1,15 +1,48 @@ var client +var globals = require('./globals.js') module.exports.init = function(myClient) { client = myClient } +function sendMsg(message, channel) { + client.say(channel, message); + var chanTab = $("[data-tab='"+ channel +"'].chat"); + chanTab.append("

<" + myNick + "> " + message +"

"); + chanTab.scrollTop(chanTab.prop("scrollHeight")); +} + +function sendPm(message, nick) { + + var chanTab = $("[data-tab="+nick+"].tab"); + $(".active").removeClass("active"); + numChans = globals.channels.length + if (chanTab.length == 0) { + $(".ui.menu").append(""+nick+""); + $("#chan-container").append("
"); + chanTab = $("[data-tab="+nick+"].tab"); + chanTab.append("
"); + + $('.menu .item').tab({history:false}); + globals.channels.push(nick) + numChans++; + } + $("[data-tab="+nick+"]").addClass("active"); + var chatTab = $("[data-tab="+nick+"].chat"); + console.log(nick + ': ' + message); + client.say(nick, message); + chatTab.append("

<" + myNick + "> " + message +"

"); + chatTab.scrollTop(chanTab.prop("scrollHeight")); +} + + module.exports.setTopic = function(channel, topic) { client.raw("TOPIC", channel, topic); } module.exports.joinChannel = function (channel, sendJoin) { + numChans = globals.channels.length var channelObj = client.channel(channel); if (sendJoin) { channelObj.join(); @@ -32,3 +65,16 @@ module.exports.joinChannel = function (channel, sendJoin) { numChans++; } + +function removeChannel(channel, sendPart) { + var channelObj = client.channel(channel) + chanId = $("[data-tab='"+channel+"'].chat").attr("data-id"); + $("[data-tab='"+channel+"']").remove(); + if (sendPart) { + channelObj.part(); + } + while ($("[data-id="+(chanId-1)+"]").length == 0 && chanId >=0) { + chanId--; + } + $("[data-id="+(chanId-1)+"]").addClass("active"); +} diff --git a/globals.js b/globals.js new file mode 100644 index 0000000..a0c689b --- /dev/null +++ b/globals.js @@ -0,0 +1,5 @@ +module.exports.channels = ['status'] + +module.exports.pms = [] + +module.exports.networks = [] diff --git a/handlers.js b/handlers.js index 9b956c3..ffbb4f4 100644 --- a/handlers.js +++ b/handlers.js @@ -2,8 +2,8 @@ var linkify = require("linkifyjs"); var linkifyHtml = require('linkifyjs/html'); var util = require("./util.js") var commands = require("./commands.js") - -var numChans = 1; +var globals = require("./globals.js") +var numChans = globals.channels.length + globals.pms.length; var channels; var client; var myNick = "" @@ -69,7 +69,7 @@ function receiveMsg(target, from, message) { // target: "_blank" // }); // console.log(message.autoLink()); - + numChans = globals.channels.length console.log(from + ' => '+ target +': ' + message); if (target === client.user.nick) { @@ -84,6 +84,7 @@ function receiveMsg(target, from, message) { chanTab.append("
"); $('.menu .item').tab({history:false}); + global.channels.push(target) numChans++; chatTab = $("[data-tab="+ target +"].chat"); } diff --git a/index.js b/index.js index d6d0a62..46eeb26 100644 --- a/index.js +++ b/index.js @@ -4,6 +4,7 @@ var config = require('./config.json') var pjson = require('./package.json'); var handlers = require('./handlers.js'); var commands = require('./commands.js'); +var globals = require('./globals.js') var debugmiddleware = require('./debugmiddleware.js'); const progName = pjson.name; const version = pjson.version; @@ -104,7 +105,7 @@ function humanize(size) { return s + ' ' + units[ord]; } -var numChans = 1; +var numChans = globals.channels.length $("#send-message").keypress(function(e) { if(e.which == 13) { var message = $("#send-message").val(); @@ -157,6 +158,7 @@ function sendPm(message, nick) { var chanTab = $("[data-tab="+nick+"].tab"); $(".active").removeClass("active"); + numChans = globals.channels.length if (chanTab.length == 0) { $(".ui.menu").append(""+nick+""); $("#chan-container").append("
"); @@ -164,6 +166,7 @@ function sendPm(message, nick) { chanTab.append("
"); $('.menu .item').tab({history:false}); + globals.channels.push(nick) numChans++; } $("[data-tab="+nick+"]").addClass("active"); -- cgit v1.2.3 From f88564402afd517c01c4bd1e8bb4d8de8afc7690 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 20:22:07 +0100 Subject: Fix whois function --- handlers.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/handlers.js b/handlers.js index ffbb4f4..0abb297 100644 --- a/handlers.js +++ b/handlers.js @@ -59,6 +59,29 @@ module.exports.handleCommands = function(myClient) { topicTab.html("

"+topic+"

") }) + client.on('whois', function(event) { + var nick = event.nick + var chatTab = $(".active .chat"); + chatTab.append("

"+event.nick+": "+event.user+"@"+event.host+"

"); + chatTab.append("

Real Name: "+event.real_name+"

"); + chatTab.append("

Channels: " + event.channels+"

"); + chatTab.append("

Server: "+event.server+" "+event.server_info+"

"); + if (event.operator.length > 0) { + chatTab.append("

"+event.operator+"

"); + } + if (event.registered_nick.length > 0) { + chatTab.append("

"+event.registered_nick+"

"); + } + if (event.away.length > 0) { + chatTab.append("

"+event.away+"

"); + } + if (event.secure) { + chatTab.append("

is using a secure connection

"); + } + chatTab.scrollTop(chatTab.prop("scrollHeight")); + + }) + } function receiveMsg(target, from, message) { -- cgit v1.2.3 From 63405f05a0406e55daf1fb4bfb00b324f2bf5f7e Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 20:38:10 +0100 Subject: Fix channel list function --- commands.js | 10 +++++- handlers.js | 13 ++++++++ index.js | 104 ++++-------------------------------------------------------- 3 files changed, 29 insertions(+), 98 deletions(-) diff --git a/commands.js b/commands.js index 6bffb76..5ab1d5e 100644 --- a/commands.js +++ b/commands.js @@ -66,7 +66,7 @@ module.exports.joinChannel = function (channel, sendJoin) { numChans++; } -function removeChannel(channel, sendPart) { +module.exports.removeChannel = function(channel, sendPart) { var channelObj = client.channel(channel) chanId = $("[data-tab='"+channel+"'].chat").attr("data-id"); $("[data-tab='"+channel+"']").remove(); @@ -78,3 +78,11 @@ function removeChannel(channel, sendPart) { } $("[data-id="+(chanId-1)+"]").addClass("active"); } + +module.exports.whois = function(nick) { + client.whois(nick); +} + +module.exports.list = function() { + client.raw("LIST") +} diff --git a/handlers.js b/handlers.js index 0abb297..c4adbd7 100644 --- a/handlers.js +++ b/handlers.js @@ -82,6 +82,19 @@ module.exports.handleCommands = function(myClient) { }) + client.on('channel list', function(event) { + var statusTab = $("[data-tab='status'].chat"); + statusTab.append("

Channel List:

") + event.forEach( function(channel) { + if (channel.topic.length == 0) { + statusTab.append("

"+channel.channel+" ("+channel.num_users+")

"); + } else { + statusTab.append("

"+channel.channel+" ("+channel.num_users+") : "+channel.topic+"

"); + } + statusTab.scrollTop(statusTab.prop("scrollHeight")); + }) + }) + } function receiveMsg(target, from, message) { diff --git a/index.js b/index.js index 46eeb26..e9a6f7c 100644 --- a/index.js +++ b/index.js @@ -116,16 +116,16 @@ $("#send-message").keypress(function(e) { if (message.length > 6) { channel = message.substring(6, message.length); } - removeChannel(channel, true); + commands.removeChannel(channel, true); } else if (message.indexOf("/whois") == 0) { - console.log("whois "+message.substring(7, message.length)); - client.whois(message.substring(7, message.length)); + commands.whois(message.substring(7, message.length)) + } else if (message.indexOf("/list") == 0) { - client.list(); + commands.list(); } else if (message.indexOf("/msg") == 0) { nick = message.split(" ")[1]; message = message.substring(6+nick.length, message.length); - sendPm(message, nick); + commands.sendPm(message, nick); } else if (message.indexOf("/topic") == 0) { var channel = $(".tab.active").attr("data-tab") topic = message.substring(7, message.length); @@ -137,58 +137,16 @@ $("#send-message").keypress(function(e) { } else { var tab = $(".tab.active").attr("data-tab"); if (tab.startsWith("#")) { - sendMsg(message, channel); + commands.sendMsg(message, channel); } else { - sendPm(message, tab); + commands.sendPm(message, tab); } } $("#send-message").val(''); } }); -function sendMsg(message, channel) { - client.say(channel, message); - var chanTab = $("[data-tab='"+ channel +"'].chat"); - chanTab.append("

<" + myNick + "> " + message +"

"); - chanTab.scrollTop(chanTab.prop("scrollHeight")); -} - -function sendPm(message, nick) { - - var chanTab = $("[data-tab="+nick+"].tab"); - $(".active").removeClass("active"); - numChans = globals.channels.length - if (chanTab.length == 0) { - $(".ui.menu").append(""+nick+""); - $("#chan-container").append("
"); - chanTab = $("[data-tab="+nick+"].tab"); - chanTab.append("
"); - - $('.menu .item').tab({history:false}); - globals.channels.push(nick) - numChans++; - } - $("[data-tab="+nick+"]").addClass("active"); - var chatTab = $("[data-tab="+nick+"].chat"); - console.log(nick + ': ' + message); - client.say(nick, message); - chatTab.append("

<" + myNick + "> " + message +"

"); - chatTab.scrollTop(chanTab.prop("scrollHeight")); -} - -function removeChannel(channel, sendPart) { - chanId = $("[data-tab='"+channel+"'].chat").attr("data-id"); - $("[data-tab='"+channel+"']").remove(); - if (sendPart) { - client.part(channel); - } - while ($("[data-id="+(chanId-1)+"]").length == 0 && chanId >=0) { - chanId--; - } - $("[data-id="+(chanId-1)+"]").addClass("active"); -} - function createListeners(client) { @@ -196,11 +154,6 @@ client.addListener('error', function(message) { console.log('error: ', message); }); -client.addListener('registered', function() { - channels.forEach(function(channel) { - joinChannel(channel, false); - }); -}); client.addListener('motd', function(motd) { var statusTab = $("[data-tab=status].chat"); @@ -267,21 +220,6 @@ client.addListener('quit', function(nick, reason, channels, message) { }); -client.addListener('pm', function(nick, text, message) { - - if($(".ui.tab[data-tab=pm-"+nick+"]").length == 0) { - $(".ui.menu").append(""+nick+""); - $("#chan-container").append("
"); - var chanTab = $("[data-tab=pm-"+ nick +"].tab"); - chanTab.append("
"); - numChans++; - $('.menu .item').tab({history:false}); - } - var chatTab = $("[data-tab=pm-"+ nick +"].chat"); - chatTab.append("

<"+nick+"> "+text+"

") - chatTab.scrollTop(chatTab.prop("scrollHeight")); -}); - client.addListener('kick', function(channel, nick, by, reason, message) { if (myNick == nick) { removeChannel(channel, false); @@ -308,34 +246,6 @@ client.addListener('kill', function(nick, reason, channels, message) { }); }); -client.addListener('topic', function(channel, topic, nick, message) { - channel = channel.replace("#",""); - var chatTab = $("[data-tab=chan-"+ channel +"].chat"); - if($(".ui.tab[data-tab=chan-"+channel+"]").length == 0) { - joinChannel(channel, false) - } - chatTab.append("

Topic for #"+channel+" is "+topic+" - set by "+nick+" at "+message.args[3]+"

") - var topicTab = $("[data-tab=chan-"+ channel +"].topic"); - topicTab.html("

"+topic+"

") -}); - -client.addListener('whois', function(info) { - console.log(info) - var chatTab = $(".active .chat"); - chatTab.append("

Nick:"+info.nick+"

"); - chatTab.append("

User:"+info.user+"

"); - chatTab.append("

Host:"+info.host+"

"); - chatTab.append("

Real Name:"+info.realname+"

"); - chatTab.append("

Channels:"); - for (channel in info.channels) { - chatTab.append(" "+info.channels[channel]) - } - chatTab.append("

") - chatTab.append("

Server:"+info.server+"

"); - chatTab.append("

Server Info:"+info.serverinfo+"

"); - chatTab.append("

"+info.operator+"

"); - chatTab.scrollTop(chatTab.prop("scrollHeight")); -}); client.addListener('+mode', function(channel, by, mode, argument, message) { console.log(message) -- cgit v1.2.3 From f13842bc63f002e456727d1a48239d4e044d0c75 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 21:05:57 +0100 Subject: Add join, part, and quit handlers --- commands.js | 2 +- handlers.js | 41 +++++++++++++++++++++++++++++++++++++++++ index.js | 54 ++++-------------------------------------------------- 3 files changed, 46 insertions(+), 51 deletions(-) diff --git a/commands.js b/commands.js index 5ab1d5e..59be364 100644 --- a/commands.js +++ b/commands.js @@ -62,7 +62,7 @@ module.exports.joinChannel = function (channel, sendJoin) { chanTab.append("
"); $('.menu .item').tab({history:false}); - + globals.channels.push(channel) numChans++; } diff --git a/handlers.js b/handlers.js index c4adbd7..e68a14d 100644 --- a/handlers.js +++ b/handlers.js @@ -95,6 +95,47 @@ module.exports.handleCommands = function(myClient) { }) }) + + client.on('join', function(event) { + var channel = event.channel + var nick = event.nick + if($(".ui.users[data-tab='"+channel+"'] [data-nick="+nick+"]").length == 0) { + $(".ui.users[data-tab='"+channel+"']").append("
"+nick+"
") + } + var chatTab = $("[data-tab='"+ channel +"'].chat"); + chatTab.append("

"+nick+" joined "+channel+"

") + }); + + client.on('part', function(event) { + var channel = event.channel + var nick = event.nick + var message = event.message + + if($(".ui.users[data-tab='"+channel+"'] [data-nick="+nick+"]").length > 0) { + $(".ui.users[data-tab='"+channel+"'] [data-nick="+nick+"]").remove(); + } + var chatTab = $("[data-tab='"+ channel +"'].chat"); + + chatTab.append("

"+nick+" left "+channel+" ("+message+")

") + chatTab.scrollTop(chatTab.prop("scrollHeight")); + }); + + client.on('quit', function(event) { + var nick = event.nick + var message = event.message + + + globals.channels.forEach(function(channel) { + if($(".ui.users[data-tab='"+channel+"'] [data-nick="+nick+"]").length > 0) { + $(".ui.users[data-tab='"+channel+"'] [data-nick="+nick+"]").remove(); + var chatTab = $("[data-tab='"+ channel +"'].chat"); + chatTab.append("

"+nick+" quit ("+message+")

") + chatTab.scrollTop(chatTab.prop("scrollHeight")); + } + + }); + }) + } function receiveMsg(target, from, message) { diff --git a/index.js b/index.js index e9a6f7c..b4333e5 100644 --- a/index.js +++ b/index.js @@ -131,9 +131,9 @@ $("#send-message").keypress(function(e) { topic = message.substring(7, message.length); commands.setTopic(channel, topic); } else if (message.indexOf("/") == 0) { - command = message.split(" ")[0].replace("/",""); - commandArgs = message.replace(command + " ", ""); - client.send("kick", ["#wtest", "wjoe__", "test"]); + // command = message.split(" ")[0].replace("/",""); + // commandArgs = message.replace(command + " ", ""); + // client.send("kick", ["#wtest", "wjoe__", "test"]); } else { var tab = $(".tab.active").attr("data-tab"); if (tab.startsWith("#")) { @@ -163,7 +163,7 @@ client.addListener('motd', function(motd) { client.addListener('raw', function(message) { var statusTab = $("[data-tab=status].chat"); - statusCmds = ["NOTICEAUTH", "rpl_welcome, rpl_yourhoust", "rpl_created", "rpl_myinfo", "rpl_isupport", "rpl_luserclient", "rpl_luserop", "rpl_luserme", "rpl_luserchannels", "rpl_localusers", "rpl_globalusers"]; + statusCmds = ["NOTICEAUTH", "rpl_welcome, rpl_yourhost", "rpl_created", "rpl_myinfo", "rpl_isupport", "rpl_luserclient", "rpl_luserop", "rpl_luserme", "rpl_luserchannels", "rpl_localusers", "rpl_globalusers"]; if (statusCmds.indexOf(message.command) > -1 || message.command.startsWith("rpl_")) { statusTab.append("

"+message.command + ": " +message.args+"

") statusTab.scrollTop(statusTab.prop("scrollHeight")); @@ -174,39 +174,6 @@ client.addListener('ctcp-version', function(from, to, text, message) { client.ctcp(from, "VERSION", "VERSION "+progName + " v"+ version) }); - -client.addListener('names', function(channel, nicks) { - channel = channel.replace("#","") - if($(".ui.tab[data-tab=chan-"+channel+"]").length == 0) { - joinChannel(channel, false) - } - for(nick in nicks) { - var mode = nicks[nick]; - if($(".ui.users[data-tab=chan-"+channel+"] [data-nick="+nick+"]").length == 0) { - $(".ui.users[data-tab=chan-"+channel+"]").append("
"+mode+nick+"
") - } - } -}); -- -client.addListener('join', function(channel, nick) { - channel = channel.replace("#","") - if($(".ui.users[data-tab=chan-"+channel+"] [data-nick="+nick+"]").length == 0) { - $(".ui.users[data-tab=chan-"+channel+"]").append("
"+nick+"
") - } - var chatTab = $("[data-tab=chan-"+ channel +"].chat"); - chatTab.append("

"+nick+" joined #"+channel+"

") -}); - -client.addListener('part', function(channel, nick) { - 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("

"+nick+" left #"+channel+"

") - chatTab.scrollTop(chatTab.prop("scrollHeight")); -}); - client.addListener('quit', function(nick, reason, channels, message) { channels.forEach(function(channel) { channel = channel.replace("#","") @@ -296,17 +263,4 @@ client.addListener('-mode', function(channel, by, mode, argument, message) { chatTab.scrollTop(chatTab.prop("scrollHeight")); }); -client.addListener('channellist', function(channelList) { - var statusTab = $("[data-tab=status].chat"); - statusTab.append("

Channel List:

") - for (i in channelList) { - if (channelList[i].topic == null) { - statusTab.append("

"+channelList[i].name+" ("+channelList[i].users+")

"); - } else { - statusTab.append("

"+channelList[i].name+" ("+channelList[i].users+") : "+channelList[i].topic+"

"); - } - statusTab.scrollTop(statusTab.prop("scrollHeight")); - } -}); - } -- cgit v1.2.3 From bf695e6ad13b0fd0fb2706d6bf9960a66e656696 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 21:22:31 +0100 Subject: Add mode handler --- handlers.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/handlers.js b/handlers.js index e68a14d..c6d86de 100644 --- a/handlers.js +++ b/handlers.js @@ -136,6 +136,43 @@ module.exports.handleCommands = function(myClient) { }); }) + client.on('mode', function(event) { + var chatTab = $("[data-tab='"+ channel +"'].chat"); + var by = event.nick + var channel = event.target + event.modes.forEach(function (modeObj) { + + var mode = modeObj.mode + var argument = modeObj.param + 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 (mode == "-o") { + modeLine = " removes channel operator status from " + argument; + } else if (mode == "-v") { + modeLine = " removes voice from "; + } else if (mode == "-h") { + modeLine = " removes channel half-operator status from " + argument; + } else if (mode == "-q") { + modeLine = " removes channel owner status from " + 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='"+ channel +"'].chat"); + chatTab.append("

"+by+modeLine+"

"); + }) + chatTab.scrollTop(chatTab.prop("scrollHeight")); + }) + } function receiveMsg(target, from, message) { -- cgit v1.2.3 From e0840642f1710a5f50d3508d3fe661fdc17d9d56 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 21:41:00 +0100 Subject: Add kick handler --- commands.js | 3 ++- globals.js | 2 ++ handlers.js | 17 ++++++++++++++++ index.js | 68 +------------------------------------------------------------ 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("

"+kicked+" was kicked from "+channel+" by "+by+" ("+reason+")

") + 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("

"+nick+" quit ("+reason+")

") - 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("

"+by+modeLine+"

"); - 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("

"+by+modeLine+"

"); - chatTab.scrollTop(chatTab.prop("scrollHeight")); -}); - } -- cgit v1.2.3 From ac48b1195c4cd68f716e4119181c720cc9ec8b4f Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 22:34:58 +0100 Subject: Handle error and server messages --- commands.js | 8 ++--- handlers.js | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- index.js | 60 ++++++-------------------------- 3 files changed, 121 insertions(+), 59 deletions(-) diff --git a/commands.js b/commands.js index 138c55f..1847b74 100644 --- a/commands.js +++ b/commands.js @@ -5,14 +5,14 @@ module.exports.init = function(myClient) { client = myClient } -function sendMsg(message, channel) { +module.exports.sendMsg = function(message, channel) { client.say(channel, message); var chanTab = $("[data-tab='"+ channel +"'].chat"); - chanTab.append("

<" + myNick + "> " + message +"

"); + chanTab.append("

<" + globals.myNick + "> " + message +"

"); chanTab.scrollTop(chanTab.prop("scrollHeight")); } -function sendPm(message, nick) { +module.exports.sendPm = function(message, nick) { var chanTab = $("[data-tab="+nick+"].tab"); $(".active").removeClass("active"); @@ -31,7 +31,7 @@ function sendPm(message, nick) { var chatTab = $("[data-tab="+nick+"].chat"); console.log(nick + ': ' + message); client.say(nick, message); - chatTab.append("

<" + myNick + "> " + message +"

"); + chatTab.append("

<" + globals.myNick + "> " + message +"

"); chatTab.scrollTop(chanTab.prop("scrollHeight")); } diff --git a/handlers.js b/handlers.js index 24b783c..9142f04 100644 --- a/handlers.js +++ b/handlers.js @@ -18,7 +18,7 @@ module.exports.handleCommands = function(myClient) { }); }); client.on('message', function(event) { - receiveMsg(event.target, event.nick, event.message) + receiveMsg(event.target, event.nick, event.message, event.from_server) }) client.on('userlist', function(event) { @@ -48,17 +48,31 @@ module.exports.handleCommands = function(myClient) { channel = event.channel topic = event.topic //TODO: Handle topicsetby to add the user and time for the topic - nick = "vov" - time = "vov" var chatTab = $("[data-tab='"+ channel +"'].chat"); if($(".ui.tab[data-tab='"+channel+"']").length == 0) { commands.joinChannel(channel, false) } - chatTab.append("

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

") + chatTab.append("

Topic for "+channel+" is "+topic+"

") var topicTab = $("[data-tab='"+ channel +"'].topic"); topicTab.html("

"+topic+"

") }) + client.on('topicsetby', function(event) { + channel = event.channel + nick = event.nick + timestamp = event.when + + //TODO: Handle topicsetby to add the user and time for the topic + + var chatTab = $("[data-tab='"+ channel +"'].chat"); + if($(".ui.tab[data-tab='"+channel+"']").length == 0) { + commands.joinChannel(channel, false) + } + chatTab.append("

Set by "+nick+" at "+timestamp+"

") + var topicLine = $("[data-tab='"+ channel +"'].topic .topic-line"); + topicLine.append(" by " + nick + " at " + timestamp) + }) + client.on('whois', function(event) { var nick = event.nick var chatTab = $(".active .chat"); @@ -160,7 +174,7 @@ module.exports.handleCommands = function(myClient) { modeLine = " removes channel half-operator status from " + argument; } else if (mode == "-q") { modeLine = " removes channel owner status from " + argument; - } else if (argument == myNick) { + } else if (argument == globals.myNick) { modeLine = " sets mode " + mode + " on " + argument; } else if (argument != null) { modeLine = " sets mode " + mode + " " + argument + " on " +channel; @@ -190,9 +204,90 @@ module.exports.handleCommands = function(myClient) { } }) + client.on('motd', function(event) { + serverMsg(event.motd) + }) + + //Server Info + //eg: Your host is irc.lc8n.com, running version Unreal3.2.10.4" + //param 0 is your nick + client.on('002', function(event) { + serverMsg(event.params[1]) + }) + + //Server created + //eg Your host is irc.lc8n.com, running version Unreal3.2.10.4" + //param 0 is your nick + client.on('003', function(event) { + serverMsg(event.params[1]) + }) + + //004: Some unknown server strings + client.on('004', function(event) { + serverMsg(event.params[1] + " " + event.params[2] + " " + event.params[3] + " " + event.params[4]) + }) + //Users online + //eg: There are 7 users and 47 invisible on 4 servers + client.on('251', function(event) { + serverMsg(event.params[1]) + }) + + //Operators online + //eg: "10" "operator(s) online" + client.on('252', function(event) { + serverMsg(event.params[1] + " " +event.params[2]) + }) + + //Channels formed + //eg "49" "channels formed" + client.on('254', function(event) { + serverMsg(event.params[1] + " " +event.params[2]) + }) + + //'Clients' and 'Servers'? + //eg "I have 8 clients and 1 servers" + client.on('255', function(event) { + serverMsg(event.params[1]) + }) + + //User stats + //eg ""Current global users 54, max 63" + //param 0 is your nick, 1 is current users, 2 is max users + client.on('266', function(event) { + serverMsg(event.params[3]) + }) + + client.on('irc error', function(event) { + errorMsg(event.error, event.reason, event.channel) + }); + + //No such channel error + client.on('403', function(event) { + errorMsg("403", event.params[2], event.params[1]) + }); } -function receiveMsg(target, from, message) { + +function errorMsg(error, message, param) { + var chatTab = $(".active .chat"); + + chatTab.append("

Error: "+error+"!

"); + if (param.length > 0) { + chatTab.append("

Param: "+param+"

"); + } + if (message.length > 0) { + chatTab.append("

Message: "+message+"

"); + } + chatTab.scrollTop(chatTab.prop("scrollHeight")); + console.log('error: ', error); +} +function serverMsg(message) { + var statusTab = $("[data-tab=status].chat"); + statusTab.append("

"+message+"

") + statusTab.scrollTop(statusTab.prop("scrollHeight")); +} + +function receiveMsg(target, from, message, from_server) { // message = message.autoLink( { // callback: function(url) { // return /\.(gif|png|jpe?g)$/i.test(url) ? '' : null; @@ -200,6 +295,11 @@ function receiveMsg(target, from, message) { // target: "_blank" // }); // console.log(message.autoLink()); + + if (from_server) { + serverMsg(message) + return false + } numChans = globals.channels.length console.log(from + ' => '+ target +': ' + message); diff --git a/index.js b/index.js index 48f55a0..1975bc0 100644 --- a/index.js +++ b/index.js @@ -148,53 +148,15 @@ $("#send-message").keypress(function(e) { } }); -function createListeners(client) { - -client.addListener('error', function(message) { - console.log('error: ', message); -}); - - -client.addListener('motd', function(motd) { - var statusTab = $("[data-tab=status].chat"); - statusTab.append("

"+motd+"

") - statusTab.scrollTop(statusTab.prop("scrollHeight")); -}); - -client.addListener('raw', function(message) { - var statusTab = $("[data-tab=status].chat"); - statusCmds = ["NOTICEAUTH", "rpl_welcome, rpl_yourhost", "rpl_created", "rpl_myinfo", "rpl_isupport", "rpl_luserclient", "rpl_luserop", "rpl_luserme", "rpl_luserchannels", "rpl_localusers", "rpl_globalusers"]; - if (statusCmds.indexOf(message.command) > -1 || message.command.startsWith("rpl_")) { - statusTab.append("

"+message.command + ": " +message.args+"

") - statusTab.scrollTop(statusTab.prop("scrollHeight")); - } -}); - -client.addListener('kick', function(channel, nick, by, reason, message) { - if (myNick == nick) { - removeChannel(channel, false); - } else { - 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("

"+nick+"was kicked from #"+channel+" by "+by+" ("+reason+")

") - chatTab.scrollTop(chatTab.prop("scrollHeight")); - } -}); - -client.addListener('kill', 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("

"+nick+" was killed by the server ("+reason+")

") - chatTab.scrollTop(chatTab.prop("scrollHeight")); - }); -}); - -} +// client.addListener('kill', 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("

"+nick+" was killed by the server ("+reason+")

") +// chatTab.scrollTop(chatTab.prop("scrollHeight")); +// }); +// }); -- cgit v1.2.3 From 6463d5922886af839627c539feb9706b5fd9c529 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 22:41:28 +0100 Subject: Remove irc.js dependency, bump version --- index.js | 6 +----- package.json | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/index.js b/index.js index 1975bc0..e65d207 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,6 @@ $(document).on('click', 'a[href^="http"]', function(event) { shell.openExternal(this.href); }); -const irc = require('irc'); const IRC = require('irc-framework'); const client = new IRC.Client() @@ -40,16 +39,13 @@ txtChannels = txtChannels.substring(0, txtChannels.length-1) $("#channel-input").val(txtChannels); $('#connect').on('click', function() { -console.log($("#channel-input").val()); server = $("#server-input").val(); port = $("#port-input").val(); channels = $("#channel-input").val().split(" "); myNick = $("#nick-input").val(); password = $("#password-input").val(); ssl = ($("#ssl-input:checked").val() == "on"); - console.log(ssl); client.use(debugmiddleware.DebugMiddleware()); - console.log(server) client.connect({ host: server, port: port, @@ -59,7 +55,7 @@ console.log($("#channel-input").val()); password: password, tls: ssl, rejectUnauthorized: false, - version: "blachat 0.1.3" + version: pjson.name + " " + pjson.version }); globals.myNick = myNick diff --git a/package.json b/package.json index de2854e..6cb5310 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blachat", - "version": "0.2.1", + "version": "0.3.0", "description": "A modern IRC client", "license": "GPL-3.0", "repository": "http://www.blatech.co.uk/wjoe/blachat", @@ -8,7 +8,6 @@ "dependencies": { "semantic-ui": "^2.1.8", "linkifyjs": "2.0.0-beta.9", - "irc": "0.5.0", "irc-framework": "2.0.0", "electron-prebuilt": "0.37.3" } } -- cgit v1.2.3 From 962b0b3382e0adec0fdc1b888eddc0a38a358888 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 22:55:33 +0100 Subject: Update changelog --- CHANGELOG | 19 ------------------- CHANGELOG.md | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 19 deletions(-) delete mode 100644 CHANGELOG create mode 100644 CHANGELOG.md diff --git a/CHANGELOG b/CHANGELOG deleted file mode 100644 index 553ee76..0000000 --- a/CHANGELOG +++ /dev/null @@ -1,19 +0,0 @@ -0.0.1 ------ - - Initial alpha release with basic IRC functionality and commands - - Support /join and /part of channels - - Can send and receive messages in channels - - PMs will be shown and can be replied to in their tab, but no way to initiate PMs - - Can send /whois and channel /list commands - - Interpret join, part, quit, kill, kick, and mode messages - - Display topics and user lists in channels -0.0.2 ------ - - Added ability to send PMs with /msg -0.1.0 ------ - - Added basic connection UI at startup (automatically populated from config.json) -0.1.1 ------ - - Create channel tab when names list is received, to support bouncers - - Added SSL connection option diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..e5e4797 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,36 @@ +0.0.1 +----- + - Initial alpha release with basic IRC functionality and commands + - Support /join and /part of channels + - Can send and receive messages in channels + - PMs will be shown and can be replied to in their tab, but no way to initiate PMs + - Can send /whois and channel /list commands + - Interpret join, part, quit, kill, kick, and mode messages + - Display topics and user lists in channels + +0.0.2 +----- + - Added ability to send PMs with /msg + - In-line Image/Video/Audio/Youtube expansion + +0.1.0 +----- + - Added basic connection UI at startup (automatically populated from config.json) + +0.1.1 +----- + - Create channel tab when names list is received, to support bouncers + - Added SSL connection option + +0.1.2 +----- + - Add /topic command + - Fix /join command + - Windows electron fix + +0.2.0 +----- + - Migrate to irc-framework library + - Includes all functionality of 0.1.2 + - Show when and who set a topic + - Show more server and error messages -- cgit v1.2.3 From 5483fbd98ebd7a6ba3827f5fe5af095fb0290655 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Sun, 16 Oct 2016 22:56:11 +0100 Subject: Correct version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6cb5310..3425300 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "blachat", - "version": "0.3.0", + "version": "0.2.0", "description": "A modern IRC client", "license": "GPL-3.0", "repository": "http://www.blatech.co.uk/wjoe/blachat", -- cgit v1.2.3