Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #42 from microp11/master

Added a handler for nick changes
  • Loading branch information...
commit 51f32913cbbce67880f27821ed133aed6692dbb2 2 parents 9293958 + c22f37a
@chrismatthieu chrismatthieu authored
Showing with 41 additions and 1 deletion.
  1. +25 −0 irc.js
  2. +16 −1 public/js/app.js
View
25 irc.js
@@ -208,6 +208,31 @@ io.sockets.on('connection', function (client) {
});
/*
+ * Handler for server reporting nick change
+ */
+ irc.addListener('nick', function (message) {
+ var prevNick = message.person.nick;
+ var newNick = message.params[0];
+ /*
+ * if ever this client will send commands, the code below will be needed
+ *
+ for (var i = 0; i < webUsers.length; i++) {
+ if (webUsers[i] == prevNick) {
+ webUsers[i] = newNick;
+ bWebUsersDirty = true;
+ break;
+ };
+ };
+ */
+ client.send(JSON.stringify({
+ messagetype: "nick",
+ from: prevNick,
+ channel: "",
+ message: newNick
+ }));
+ });
+
+ /*
* Handler for a motd line, 372
* There are multiple calls as such until the entire motd is received
* Note: not all servers emit a motd!
View
17 public/js/app.js
@@ -182,7 +182,7 @@ $(document).ready(function(){
}
};
- var appendEvent = function (from, event, isSelf) {
+ var appendEvent = function (from, event, isSelf, extra) {
var row = $('<tr/>');
if (typeof isSelf !== 'undefined' && isSelf === true) {
row.addClass('me btn btn-info');
@@ -200,6 +200,9 @@ $(document).ready(function(){
case "part":
message = "<strong>left the channel</strong>";
break;
+ case "nick":
+ message = "<strong>is now known as " + extra + "</strong>";
+ break;
case "endmotd":
message = motd;
break;
@@ -378,6 +381,18 @@ $(document).ready(function(){
nicksToList();
requestStatistics();
break;
+ case "nick":
+ appendEvent(obj.from, obj.messagetype, isSelf, obj.message);
+ for (var i = 0; i < nicks.length; i++) {
+ if (nicks[i] == obj.from) {
+ nicks[i] = obj.message;
+ break;
+ }
+ }
+ nicks.sort(cisort);
+ nicksToList();
+ //requestStatistics(); this call will be needed if the web client will also send commends
+ break;
case "statistics":
c.updateStats(obj);
if (obj.wud == true) {
Please sign in to comment.
Something went wrong with that request. Please try again.