Exemplo n.º 1
0
        private static async Task ctcpPingVersionHandler(IrcClient client,
                                                         Message message)
        {
            if (message.Prefix.ClientId == null ||
                !message.Parameters.Any() ||
                message.Parameters[0].IsChannel())
            {
                // Allow only private messages to us.
                return;
            }
            var         ctcpMessage      = message.CtcpMessage;
            CtcpMessage replyCtcpMessage = null;

            switch (ctcpMessage.Command)
            {
            case "PING":
                replyCtcpMessage = ctcpMessage;
                break;

            case "VERSION":
                replyCtcpMessage = new CtcpMessage("VERSION", "TPPCore");
                break;
            }

            if (replyCtcpMessage != null)
            {
                var reply = new Message(
                    "NOTICE",
                    new[] { message.Prefix.ClientId.Nickname },
                    replyCtcpMessage
                    );
                await client.SendMessage(reply);
            }
        }
Exemplo n.º 2
0
 public Message(string command, string[] parameters,
                CtcpMessage ctcpMessage)
     : this(command, parameters, ctcpMessage.ToString())
 {
 }