Exemple #1
0
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            if (DateTime.Now.Subtract(lastdoge).Seconds <= 10)
            {
                var prefix = actionSpan.Match.Groups[1].ToString();
                var word   = actionSpan.Match.Groups[2].ToString();

                var thesaurus = new Thesaurus(word);

                if (thesaurus.Success)
                {
                    var message = "";

                    foreach (var p in DogeRegEx)
                    {
                        if (thesaurus.Synonyms.Count == 0)
                        {
                            break;
                        }
                        if (p != prefix)
                        {
                            var pos = rnd.Next(thesaurus.Synonyms.Count - 1);
                            message += p + " " + thesaurus.Synonyms[pos] + "\n";
                            thesaurus.Synonyms.RemoveAt(pos);
                        }
                    }

                    messageSink(message);
                }
            }

            lastdoge = DateTime.Now;
        }
Exemple #2
0
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            var httpRequest  = WebRequest.Create(actionSpan.Data);
            var httpResponse = httpRequest.GetResponse();

            messageSink("URL Redirect: " + httpResponse.ResponseUri.AbsoluteUri);
        }
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            var vineid = actionSpan.Match.Groups[2].ToString();

            var vine = new Vine(vineid);

            messageSink("Vine: " + vine.Title + " By: " + vine.Author);
        }
Exemple #4
0
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            var amazon = new Amazon(actionSpan.Match.ToString());

            if (amazon.Success)
            {
                messageSink("Amazon: " + amazon.Title + "\n\t" + amazon.Price);
            }
        }
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            var username = actionSpan.Match.Groups[2].ToString();
            var tweetId  = ulong.Parse(actionSpan.Match.Groups[3].ToString());

            var tweet = new Tweet(tweetId);

            if (!tweet.Valid)
            {
                return;
            }

            var ttext = Regex.Replace(tweet.Text, "(pic\\.twitter\\.com/[a-zA-Z0-9_]+)", "http://$1");

            messageSink("Twitter: " + username + ": " + ttext + "\n        Posted: " +
                        tweet.Date.ToString("dd MMMM yyyy"));
        }
Exemple #6
0
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            double amount         = 0;
            var    sourceCurrency = "";

            if (actionSpan.Data == "1")
            {
                sourceCurrency = actionSpan.Match.Groups[1].ToString();
                amount         = double.Parse(actionSpan.Match.Groups[2].ToString());
            }
            else if (actionSpan.Data == "2")
            {
                sourceCurrency = actionSpan.Match.Groups[2].ToString();
                amount         = double.Parse(actionSpan.Match.Groups[1].ToString());
            }

            if (sourceCurrency == "$")
            {
                sourceCurrency = "USD";
            }
            else if (sourceCurrency == "£")
            {
                sourceCurrency = "GBP";
            }
            else if (sourceCurrency == "€")
            {
                sourceCurrency = "EUR";
            }

            var message = amount.ToString("0.00") + " " + sourceCurrency.ToUpper();

            foreach (var destinationCurrency in Currencies)
            {
                if (sourceCurrency.ToLower() == destinationCurrency.ToLower())
                {
                    continue;
                }

                message += "\n        " +
                           CurrencyConverter.Convert(amount, sourceCurrency, destinationCurrency).ToString("0.00") + " " +
                           destinationCurrency;
            }

            messageSink(message);
        }
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            var url       = actionSpan.Data;
            var webClient = new WebClient();

            webClient.Encoding = Encoding.UTF8;
            var html = webClient.DownloadString(url);

            if (html == null)
            {
                return;
            }

            var match = new Regex("<title>([^<]+)</title>", RegexOptions.IgnoreCase).Match(html);

            if (match == null)
            {
                return;
            }

            messageSink(WebUtility.HtmlDecode(match.Groups[1].ToString()));
        }
Exemple #8
0
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            var paste = new Paste(actionSpan.Data);

            if (!paste.Exists)
            {
                return;
            }

            var lines = paste.Data.Substring(0, 256).Split('\n');

            var  code      = "";
            uint lineCount = 0;

            foreach (var line in lines)
            {
                if (line.Trim().Length == 0)
                {
                    continue;
                }

                code = code + "\n        " + line.Replace("\t", "        ");
                lineCount++;

                if (lineCount >= 3)
                {
                    break;
                }
                if (code.Length > 256)
                {
                    break;
                }
            }

            messageSink("Pastebin:" + code);
        }
        public void HandleSpan(MessageSink messageSink, MessageActionSpan actionSpan)
        {
            var videoId = actionSpan.Data;

            var videoInfo = new VideoInfo(ulong.Parse(videoId));

            string formattedDuration = null;

            if (videoInfo.Duration.TotalHours < 1)
            {
                formattedDuration = videoInfo.Duration.Minutes.ToString("D2") + ":" +
                                    videoInfo.Duration.Seconds.ToString("D2");
            }
            else
            {
                formattedDuration = ((int)videoInfo.Duration.TotalHours).ToString("D2") + ":" +
                                    videoInfo.Duration.Minutes.ToString("D2") + ":" +
                                    videoInfo.Duration.Seconds.ToString("D2");
            }

            var videoInfoMessage = "Vimeo: " + videoInfo.Title + " [" + formattedDuration + "]";

            messageSink(videoInfoMessage);
        }