Added a ClientSettings field to specify whether a random nickname should be generated and added a check in IrcUser constructor if there is a hostname included

This commit is contained in:
Yavor 2014-01-17 05:15:42 +02:00
parent 78583783f1
commit 701f702436
3 changed files with 14 additions and 2 deletions

View File

@ -11,6 +11,7 @@ namespace ChatSharp
{
WhoIsOnConnect = true;
ModeOnJoin = true;
GenerateRandomNickIfRefused = true;
}
/// <summary>
@ -24,5 +25,9 @@ namespace ChatSharp
/// IrcChannel.Mode will be null until the mode is explicitly requested.
/// </summary>
public bool ModeOnJoin { get; set; }
/// <summary>
/// If true, the library will generate a random nick with alphanumerical characters if it
/// encounters a NICK error.
public bool GenerateRandomNickIfRefused { get; set; }
}
}

View File

@ -83,7 +83,7 @@ namespace ChatSharp.Handlers
if (message.Command == "433") // Nick in use
client.OnNickInUse(eventArgs);
// else ... TODO
if (!eventArgs.DoNotHandle)
if (!eventArgs.DoNotHandle && client.Settings.GenerateRandomNickIfRefused)
client.Nick(eventArgs.NewNick);
}

View File

@ -20,7 +20,14 @@ namespace ChatSharp
string[] mask = host.Split('@', '!');
Nick = mask[0];
User = mask[1];
Hostname = mask[2];
if (mask.Length <= 2)
{
Hostname = "";
}
else
{
Hostname = mask[2];
}
}
}