Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

I feel like otters so I'll just say I made these files better

  • Loading branch information...
commit 6fcd1db6101d78cca93a590b44bae9263843bbbf 1 parent ff362ab
@dsamarin dsamarin authored
Showing with 29 additions and 10 deletions.
  1. +27 −10 lib/irc/client.js
  2. +2 −0  lib/irc/index.js
View
37 lib/irc/client.js
@@ -115,8 +115,16 @@ Client.prototype.parse = function(incoming) {
Client.prototype.parse_prefix = function(prefix) {
- var match = prefix.match(/^:(.*)!/);
- return match[1];
+ var match = prefix.match(/^:(.*)!(\S+)@(\S+)/);
+ if (match) {
+ return {
+ nick: match[1],
+ user: match[2],
+ host: match[3]
+ };
+ } else {
+ return null;
+ }
};
@@ -128,16 +136,23 @@ Client.prototype.get_channel = function(name) {
};
-Client.prototype.get_user = function(name) {
- if (typeof this.users[name] === "undefined") {
- return this.users[name] = new Client.User(this, name);
+Client.prototype.get_user = function(nick) {
+ if (typeof this.users[nick] === "undefined") {
+ return this.users[nick] = new Client.User(this, nick);
}
- return this.users[name];
+ return this.users[nick];
};
Client.prototype.get_user_from_prefix = function(prefix) {
- return this.get_user(this.parse_prefix(prefix));
+ var parse, user;
+ parse = this.parse_prefix(prefix);
+ user = this.get_user(parse.nick);
+
+ if (!user.user) user.user = parse.user;
+ if (!user.host) user.host = parse.host;
+
+ return user;
};
@@ -266,7 +281,7 @@ Client.prototype.events = {
break;
case "NICK":
- var oldname = this.parse_prefix(message.prefix);
+ var oldname = this.parse_prefix(message.prefix).nick;
var user = this.get_user(oldname);
user.name = message.message;
@@ -513,9 +528,11 @@ Client.Channel.prototype.set_topic = function(topic) {
};
-Client.User = function(client, name) {
+Client.User = function(client, nick, user, host) {
this.client = client;
- this.name = name;
+ this.name = nick;
+ this.user = user;
+ this.host = host;
};
util.inherits(Client.User, Client.Channel);
View
2  lib/irc/index.js
@@ -280,6 +280,8 @@ Bot.prototype.listeners = {
}
},
message: function(channel, user, text) {
+
+ this.emit("message", channel, user, text);
var context = {
channel: channel,
Please sign in to comment.
Something went wrong with that request. Please try again.