Exemplo n.º 1
0
        /// <summary>
        /// Send string command and parameters with trailing parameter.
        /// </summary>
        /// <remarks>
        /// This is a convenience method to skip creating a new message object.
        /// To send without a trailing parameter <see cref="SendParams"/>.
        /// </remarks>
        public static async Task SendParamsTrailing(this IrcClient client,
                                                    string command, params string[] parameters)
        {
            string[] leadingParams = null;
            String   trailingParam = null;

            if (parameters.Length > 0)
            {
                var leadingCount = parameters.Length - 1;
                leadingParams = parameters.Take(leadingCount).ToArray();
                trailingParam = parameters.Last();
            }

            await client.SendMessage(
                new Message(command, leadingParams, trailingParam));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends a PRIVMSG.
        /// </summary>
        public static async Task Privmsg(this IrcClient client,
                                         string destination, string text, bool action = false)
        {
            Message message;

            if (action)
            {
                message = new Message("PRIVMSG", new[] { destination },
                                      new CtcpMessage("ACTION", text));
            }
            else
            {
                message = new Message("PRIVMSG", new[] { destination }, text);
            }

            await client.SendMessage(message);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Send string command and parameters.
 /// </summary>
 /// <remarks>
 /// This is a convenience method to skip creating a new message object.
 /// To send a tailing parameter, use <see cref="SendParamsTrailing"/>.
 /// </remarks>
 public static async Task SendParams(this IrcClient client,
                                     string command, params string[] parameters)
 {
     await client.SendMessage(new Message(command, parameters));
 }
Exemplo n.º 4
0
 private static async Task pingHandler(IrcClient client, Message message)
 {
     await client.SendMessage(new Message(
                                  "PONG", null, message.TrailingParameter));
 }