Пример #1
0
        /// <summary>
        /// Handles a message from the channel.
        /// </summary>
        /// <param name="writer">The IRC Writer to write to.</param>
        /// <param name="response">The response from the channel.</param>
        private async void HandleMessage(IIrcWriter writer, IrcResponse response)
        {
            string url;

            if (UrlReader.TryParseUrl(response.Message, out url))
            {
                StringBuilder builder = new StringBuilder();
                builder.AppendFormat("@{0}: Here's a description of that URL: ", response.RemoteUser);
                builder.Append(await this.urlReader.GetDescription(url));

                writer.SendMessageToUser(
                    builder.ToString(),
                    response.Channel
                    );
            }
        }
Пример #2
0
        /// <summary>
        /// Handles a message from the channel.
        /// </summary>
        private async void HandleMessage(MessageHandlerArgs args)
        {
            string url;

            if (UrlReader.TryParseUrl(args.Message, out url))
            {
                UrlResponse urlResponse = await this.urlReader.AsyncGetDescription(url);

                if (urlResponse.IsValid)
                {
                    args.Writer.SendMessage(
                        string.Format("Title: {0}", urlResponse.TitleShortened),
                        args.Channel
                        );
                }
            }
        }