Example #1
0
 private static Tweet CreateTweet(TwitterSearchResult result) {
     return new Tweet {
         ImageSource = result.ProfileImageLocation,
         Name = string.Format("@{0}, {1:dd.MMM HH:mm} via {2}",
             result.FromUserScreenName, result.CreatedDate, ExtractApplicationName(result.Source)),
         Text = HtmlEntity.DeEntitize(result.Text)
     };
 }
Example #2
0
        public static void RespondToTweet(TwitterSearchResult tweet)
        {
            var arrive_or_depart = "";
            if (tweet.Text.Contains("arrive"))
            {
                arrive_or_depart = "arrive";
            }
            else if(tweet.Text.Contains("leave") || tweet.Text.Contains("depart"))
            {
                arrive_or_depart = "depart";
            }
            else
            {
                // we're not sure - respond to both...
                arrive_or_depart = "either";
            }

            if (tweet.CreatedDate > DateTime.Now.AddMinutes(-int.Parse(System.Configuration.ConfigurationManager.AppSettings["SchedulePeriod"])))
            {
                if (arrive_or_depart != "depart")
                {
                    foreach (var a in GetArrivals())
                    {
                        var tweetWords = tweet.Text.Split(" ".ToCharArray());
                        foreach (var w in tweetWords.Where(w => (w == a.flight_number) || (w == a.from)))
                        {
                            var arrivaltime = DateTime.Parse(a.date + " " + a.scheduled_arrival_time);
                            var bodyText = "will be arriving";
                            if (arrivaltime < DateTime.Now)
                            {
                                bodyText = "arrived";
                            }

                            Tweet(string.Format("@{4}: Flight {0} from {3} {2} at {1}.", a.flight_number,
                                                a.scheduled_arrival_time, bodyText, a.from, tweet.FromUserScreenName));
                        }
                    }
                }

                if (arrive_or_depart != "arrive")
                {
                    foreach (var d in GetDepartures())
                    {
                        var tweetWords = tweet.Text.Split(" ".ToCharArray());
                        foreach (var w in tweetWords.Where(w => (w == d.flight_number) || (w == d.destination)))
                        {
                            var arrivaltime = DateTime.Parse(d.date + " " + d.scheduled_departure_time);
                            var bodyText = "will be leaving";
                            if (arrivaltime < DateTime.Now)
                            {
                                bodyText = "left";
                            }

                            Tweet(string.Format("@{4}: Flight {0} to {3} {2} at {1}.", d.flight_number,
                                                d.scheduled_departure_time, bodyText, d.destination,
                                                tweet.FromUserScreenName));
                        }
                    }
                }

            }
        }
Example #3
0
 protected string getTweetFormated(TwitterSearchResult tweet) 
 {
     return string.Format(@"<div style=""color:#666; background-color: #eee; border: 1px solid #ccc; padding: 5px; margin-bottom: 5px; font-family: verdana; font-size: 12px;""><p><b style=""color:#000;""><a target=""_blank"" href=""http://twitter.com/#!/{0}""></b>{0}</b></a>: {1}</p></div>", tweet.FromUserScreenName, this.LinkifyText(tweet.Text));
 }