Merge pull request #89 from RockyTV/caps
Add support for account-notify cap
This commit is contained in:
commit
274a5721f3
|
@ -18,6 +18,14 @@ namespace ChatSharp.Handlers
|
||||||
if (!user.Channels.Contains(channel))
|
if (!user.Channels.Contains(channel))
|
||||||
user.Channels.Add(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));
|
client.OnUserJoinedChannel(new ChannelUserEventArgs(channel, user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace ChatSharp.Handlers
|
||||||
client.SetHandler("319", UserHandlers.HandleWhoIsChannels);
|
client.SetHandler("319", UserHandlers.HandleWhoIsChannels);
|
||||||
client.SetHandler("330", UserHandlers.HandleWhoIsLoggedInAs);
|
client.SetHandler("330", UserHandlers.HandleWhoIsLoggedInAs);
|
||||||
client.SetHandler("354", UserHandlers.HandleWhox);
|
client.SetHandler("354", UserHandlers.HandleWhox);
|
||||||
|
client.SetHandler("ACCOUNT", UserHandlers.HandleAccount);
|
||||||
|
|
||||||
// Listing handlers
|
// Listing handlers
|
||||||
client.SetHandler("367", ListingHandlers.HandleBanListPart);
|
client.SetHandler("367", ListingHandlers.HandleBanListPart);
|
||||||
|
|
|
@ -164,7 +164,7 @@ namespace ChatSharp.Handlers
|
||||||
|
|
||||||
if ((fields & WhoxField.AccountName) != 0)
|
if ((fields & WhoxField.AccountName) != 0)
|
||||||
{
|
{
|
||||||
whox.Account = message.Parameters[fieldIdx];
|
whox.User.Account = message.Parameters[fieldIdx];
|
||||||
fieldIdx++;
|
fieldIdx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,5 +198,11 @@ namespace ChatSharp.Handlers
|
||||||
request.Callback?.Invoke(request);
|
request.Callback?.Invoke(request);
|
||||||
client.OnWhoxReceived(new Events.WhoxReceivedEventArgs(whoxList.ToArray()));
|
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];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,22 @@ namespace ChatSharp
|
||||||
joinCmd += string.Format(" {0}", key);
|
joinCmd += string.Format(" {0}", key);
|
||||||
|
|
||||||
SendRawMessage(joinCmd, channel);
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -168,7 +168,8 @@ namespace ChatSharp
|
||||||
|
|
||||||
// List of supported capabilities
|
// List of supported capabilities
|
||||||
Capabilities.AddRange(new string[] {
|
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;
|
IsNegotiatingCapabilities = false;
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace ChatSharp
|
||||||
{
|
{
|
||||||
Channels = new ChannelCollection();
|
Channels = new ChannelCollection();
|
||||||
ChannelModes = new Dictionary<IrcChannel, List<char?>>();
|
ChannelModes = new Dictionary<IrcChannel, List<char?>>();
|
||||||
|
Account = "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -97,6 +98,11 @@ namespace ChatSharp
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The channels.</value>
|
/// <value>The channels.</value>
|
||||||
public ChannelCollection Channels { get; set; }
|
public ChannelCollection Channels { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// The user's account. If 0 or *, the user is not logged in.
|
||||||
|
/// Otherwise, the user is logged in with services.
|
||||||
|
/// </summary>
|
||||||
|
public string Account { get; set; }
|
||||||
|
|
||||||
internal Dictionary<IrcChannel, List<char?>> ChannelModes { get; set; }
|
internal Dictionary<IrcChannel, List<char?>> ChannelModes { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ namespace ChatSharp
|
||||||
Flags = string.Empty;
|
Flags = string.Empty;
|
||||||
Hops = -1;
|
Hops = -1;
|
||||||
TimeIdle = -1;
|
TimeIdle = -1;
|
||||||
Account = "*";
|
|
||||||
OpLevel = "n/a";
|
OpLevel = "n/a";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +56,6 @@ namespace ChatSharp
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int TimeIdle { get; internal set; }
|
public int TimeIdle { get; internal set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// User account name (NickServ or similar)
|
|
||||||
/// </summary>
|
|
||||||
public string Account { get; internal set; }
|
|
||||||
/// <summary>
|
|
||||||
/// OP level of the user in the channel
|
/// OP level of the user in the channel
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string OpLevel { get; internal set; }
|
public string OpLevel { get; internal set; }
|
||||||
|
|
Loading…
Reference in New Issue