Throw IOE if destination is null on messages
This commit is contained in:
parent
68dba861b7
commit
57a01ca85f
|
@ -20,7 +20,7 @@ namespace ChatSharp
|
||||||
public void SendMessage(string message, params string[] destinations)
|
public void SendMessage(string message, params string[] destinations)
|
||||||
{
|
{
|
||||||
const string illegalCharacters = "\r\n\0";
|
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");
|
if (illegalCharacters.Any(message.Contains)) throw new ArgumentException("Illegal characters are present in message.", "message");
|
||||||
string to = string.Join(",", destinations);
|
string to = string.Join(",", destinations);
|
||||||
SendRawMessage("PRIVMSG {0} :{1}{2}", to, PrivmsgPrefix, message);
|
SendRawMessage("PRIVMSG {0} :{1}{2}", to, PrivmsgPrefix, message);
|
||||||
|
@ -32,22 +32,22 @@ namespace ChatSharp
|
||||||
public void SendAction(string message, params string[] destinations)
|
public void SendAction(string message, params string[] destinations)
|
||||||
{
|
{
|
||||||
const string illegalCharacters = "\r\n\0";
|
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");
|
if (illegalCharacters.Any(message.Contains)) throw new ArgumentException("Illegal characters are present in message.", "message");
|
||||||
string to = string.Join(",", destinations);
|
string to = string.Join(",", destinations);
|
||||||
SendRawMessage("PRIVMSG {0} :\x0001ACTION {1}{2}\x0001", to, PrivmsgPrefix, message);
|
SendRawMessage("PRIVMSG {0} :\x0001ACTION {1}{2}\x0001", to, PrivmsgPrefix, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a NOTICE to one or more destinations (channels or users).
|
/// Sends a NOTICE to one or more destinations (channels or users).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendNotice(string message, params string[] destinations)
|
public void SendNotice(string message, params string[] destinations)
|
||||||
{
|
{
|
||||||
const string illegalCharacters = "\r\n\0";
|
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 mesasge.", "message");
|
if (illegalCharacters.Any(message.Contains)) throw new ArgumentException("Illegal characters are present in message.", "message");
|
||||||
string to = string.Join(",", destinations);
|
string to = string.Join(",", destinations);
|
||||||
SendRawMessage("NOTICE {0} :{1}{2}", to, PrivmsgPrefix, message);
|
SendRawMessage("NOTICE {0} :{1}{2}", to, PrivmsgPrefix, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue