Throw IOE if destination is null on messages

This commit is contained in:
Alexandre Oliveira 2015-08-25 14:36:34 -03:00
parent 68dba861b7
commit 57a01ca85f
1 changed files with 11 additions and 11 deletions

View File

@ -20,7 +20,7 @@ namespace ChatSharp
public void SendMessage(string message, params string[] destinations)
{
const string illegalCharacters = "\r\n\0";
if (!destinations.Any()) throw new InvalidOperationException("Message must have at least one target.");
if (destinations == null || !destinations.Any()) throw new InvalidOperationException("Message must have at least one target.");
if (illegalCharacters.Any(message.Contains)) throw new ArgumentException("Illegal characters are present in message.", "message");
string to = string.Join(",", destinations);
SendRawMessage("PRIVMSG {0} :{1}{2}", to, PrivmsgPrefix, message);
@ -32,22 +32,22 @@ namespace ChatSharp
public void SendAction(string message, params string[] destinations)
{
const string illegalCharacters = "\r\n\0";
if (!destinations.Any()) throw new InvalidOperationException("Message must have at least one target.");
if (destinations == null || !destinations.Any()) throw new InvalidOperationException("Message must have at least one target.");
if (illegalCharacters.Any(message.Contains)) throw new ArgumentException("Illegal characters are present in message.", "message");
string to = string.Join(",", destinations);
SendRawMessage("PRIVMSG {0} :\x0001ACTION {1}{2}\x0001", to, PrivmsgPrefix, message);
}
/// <summary>
/// Sends a NOTICE to one or more destinations (channels or users).
/// <summary>
/// Sends a NOTICE to one or more destinations (channels or users).
/// </summary>
public void SendNotice(string message, params string[] destinations)
{
const string illegalCharacters = "\r\n\0";
if (!destinations.Any()) throw new InvalidOperationException("Message must have at least one target.");
if (illegalCharacters.Any(message.Contains)) throw new ArgumentException("Illegal characters are present in mesasge.", "message");
string to = string.Join(",", destinations);
SendRawMessage("NOTICE {0} :{1}{2}", to, PrivmsgPrefix, message);
public void SendNotice(string message, params string[] destinations)
{
const string illegalCharacters = "\r\n\0";
if (destinations == null || !destinations.Any()) throw new InvalidOperationException("Message must have at least one target.");
if (illegalCharacters.Any(message.Contains)) throw new ArgumentException("Illegal characters are present in message.", "message");
string to = string.Join(",", destinations);
SendRawMessage("NOTICE {0} :{1}{2}", to, PrivmsgPrefix, message);
}
/// <summary>