diff --git a/ChatSharp/Handlers/ChannelHandlers.cs b/ChatSharp/Handlers/ChannelHandlers.cs
index ba70359..259d5d4 100644
--- a/ChatSharp/Handlers/ChannelHandlers.cs
+++ b/ChatSharp/Handlers/ChannelHandlers.cs
@@ -18,6 +18,14 @@ namespace ChatSharp.Handlers
if (!user.Channels.Contains(channel))
user.Channels.Add(channel);
+ // account-notify capability
+ if (client.Capabilities.IsEnabled("account-notify"))
+ client.Who(user.Nick, WhoxFlag.None, WhoxField.Nick | WhoxField.AccountName, (whoQuery) =>
+ {
+ if (whoQuery.Count == 1)
+ user.Account = whoQuery[0].User.Account;
+ });
+
client.OnUserJoinedChannel(new ChannelUserEventArgs(channel, user));
}
}
diff --git a/ChatSharp/Handlers/MessageHandlers.cs b/ChatSharp/Handlers/MessageHandlers.cs
index 855078a..26c6a6b 100644
--- a/ChatSharp/Handlers/MessageHandlers.cs
+++ b/ChatSharp/Handlers/MessageHandlers.cs
@@ -47,6 +47,7 @@ namespace ChatSharp.Handlers
client.SetHandler("319", UserHandlers.HandleWhoIsChannels);
client.SetHandler("330", UserHandlers.HandleWhoIsLoggedInAs);
client.SetHandler("354", UserHandlers.HandleWhox);
+ client.SetHandler("ACCOUNT", UserHandlers.HandleAccount);
// Listing handlers
client.SetHandler("367", ListingHandlers.HandleBanListPart);
diff --git a/ChatSharp/Handlers/UserHandlers.cs b/ChatSharp/Handlers/UserHandlers.cs
index 1a51c04..c8be1b0 100644
--- a/ChatSharp/Handlers/UserHandlers.cs
+++ b/ChatSharp/Handlers/UserHandlers.cs
@@ -164,7 +164,7 @@ namespace ChatSharp.Handlers
if ((fields & WhoxField.AccountName) != 0)
{
- whox.Account = message.Parameters[fieldIdx];
+ whox.User.Account = message.Parameters[fieldIdx];
fieldIdx++;
}
@@ -198,5 +198,11 @@ namespace ChatSharp.Handlers
request.Callback?.Invoke(request);
client.OnWhoxReceived(new Events.WhoxReceivedEventArgs(whoxList.ToArray()));
}
+
+ public static void HandleAccount(IrcClient client, IrcMessage message)
+ {
+ var user = client.Users.GetOrAdd(message.Prefix);
+ user.Account = message.Parameters[0];
+ }
}
}
diff --git a/ChatSharp/IrcClient.Commands.cs b/ChatSharp/IrcClient.Commands.cs
index 4c07fdc..b07d0fc 100644
--- a/ChatSharp/IrcClient.Commands.cs
+++ b/ChatSharp/IrcClient.Commands.cs
@@ -84,6 +84,22 @@ namespace ChatSharp
joinCmd += string.Format(" {0}", key);
SendRawMessage(joinCmd, channel);
+
+ // account-notify capability
+ var flags = WhoxField.Nick | WhoxField.Hostname | WhoxField.AccountName | WhoxField.Username;
+
+ if (Capabilities.IsEnabled("account-notify"))
+ Who(channel, WhoxFlag.None, flags, (whoList) =>
+ {
+ if (whoList.Count > 0)
+ {
+ foreach (var whoQuery in whoList)
+ {
+ var user = Users.GetOrAdd(whoQuery.User.Hostmask);
+ user.Account = whoQuery.User.Account;
+ }
+ }
+ });
}
///
diff --git a/ChatSharp/IrcClient.cs b/ChatSharp/IrcClient.cs
index 4a94b7a..de17a8e 100644
--- a/ChatSharp/IrcClient.cs
+++ b/ChatSharp/IrcClient.cs
@@ -168,7 +168,8 @@ namespace ChatSharp
// List of supported capabilities
Capabilities.AddRange(new string[] {
- "server-time", "multi-prefix", "cap-notify", "znc.in/server-time", "znc.in/server-time-iso"
+ "server-time", "multi-prefix", "cap-notify", "znc.in/server-time", "znc.in/server-time-iso",
+ "account-notify"
});
IsNegotiatingCapabilities = false;
diff --git a/ChatSharp/IrcUser.cs b/ChatSharp/IrcUser.cs
index a1d9e24..e66af9b 100644
--- a/ChatSharp/IrcUser.cs
+++ b/ChatSharp/IrcUser.cs
@@ -13,6 +13,7 @@ namespace ChatSharp
{
Channels = new ChannelCollection();
ChannelModes = new Dictionary>();
+ Account = "*";
}
///
@@ -97,6 +98,11 @@ namespace ChatSharp
///
/// The channels.
public ChannelCollection Channels { get; set; }
+ ///
+ /// The user's account. If 0 or *, the user is not logged in.
+ /// Otherwise, the user is logged in with services.
+ ///
+ public string Account { get; set; }
internal Dictionary> ChannelModes { get; set; }
diff --git a/ChatSharp/WhoX.cs b/ChatSharp/WhoX.cs
index 2c4a9d7..0c1484e 100644
--- a/ChatSharp/WhoX.cs
+++ b/ChatSharp/WhoX.cs
@@ -19,7 +19,6 @@ namespace ChatSharp
Flags = string.Empty;
Hops = -1;
TimeIdle = -1;
- Account = "*";
OpLevel = "n/a";
}
@@ -57,10 +56,6 @@ namespace ChatSharp
///
public int TimeIdle { get; internal set; }
///
- /// User account name (NickServ or similar)
- ///
- public string Account { get; internal set; }
- ///
/// OP level of the user in the channel
///
public string OpLevel { get; internal set; }