Compare channels by their names

- Talking in #ircdocs, a channel name is unique when server case mapping is applied.
- In short, #abc == #abc, #Abc != #abc
This commit is contained in:
Alexandre Oliveira 2017-08-25 22:16:19 -03:00
parent 879580ccde
commit 30345b81fd
2 changed files with 30 additions and 1 deletions

View File

@ -10,8 +10,8 @@ namespace ChatSharp.Handlers
{
public static void HandleJoin(IrcClient client, IrcMessage message)
{
var channel = client.Channels.GetOrAdd(message.Parameters[0]);
var user = client.Users.GetOrAdd(message.Prefix);
var channel = client.Channels.GetOrAdd(message.Parameters[0]);
if (channel != null)
{

View File

@ -107,5 +107,34 @@ namespace ChatSharp
{
Client.ChangeMode(Name, change);
}
/// <summary>
/// True if this channel is equal to another (compares names).
/// </summary>
/// <returns></returns>
public bool Equals(IrcChannel other)
{
return other.Name == Name;
}
/// <summary>
/// True if this channel is equal to another (compares names).
/// </summary>
/// <returns></returns>
public override bool Equals(object obj)
{
if (obj is IrcChannel)
return Equals((IrcChannel)obj);
return false;
}
/// <summary>
/// Returns the hash code of the channel's name.
/// </summary>
/// <returns></returns>
public override int GetHashCode()
{
return Name.GetHashCode();
}
}
}