public void PrintTweet(Tweet t)
        {
            teletype.SwitchOn();

            teletype.WaitForTT(2000);

            teletype.Bell();
            teletype.Bell();

            PrintTweetText(t.Text);
            teletype.CRLF();
            teletype.Print(string.Format("Tweeted by : {0} (@{1})", t.Author, t.ScreenName));
            teletype.CRLF();
            teletype.CRLF();

            teletype.WaitForTT(2000);

            teletype.SwitchOff();

            teletype.WaitForTT(2000);
        }
 public bool TweetMatches(Tweet t)
 {
     return true;
 }
 public bool TweetMatches(Tweet t)
 {
     return t.IsRetweet;
 }
        void timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                string url;

                Logger.Instance.Write(Environment.NewLine + "Tweeter polling for {0}", CurrentSearchTerm);

                if (string.IsNullOrEmpty(lastId))
                    url = string.Format(queryUris.InitialQuery, HttpUtility.UrlEncode(CurrentSearchTerm));
                else
                    url = string.Format(queryUris.SubsequentQuery, HttpUtility.UrlEncode(CurrentSearchTerm), lastId);

                Logger.Instance.Write("Fetching {0}", url);

                ServicePointManager.Expect100Continue = false;
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
                webRequest.Headers[HttpRequestHeader.Authorization] = authHeader;
                webRequest.ContentType = "application/x-www-form-urlencoded";
                webRequest.Method = "GET";

                var webResponse = webRequest.GetResponse();
                var json = string.Empty;
                using (var reader = new StreamReader(webResponse.GetResponseStream()))
                    json = reader.ReadToEnd();

                var dj = DynamicJson.Parse(json);
                var tweets = queryUris.ResultSelector(dj);

                foreach (var jt in tweets)
                {
                    var tweet = new Tweet
                    {
                        Author = jt.user.name,
                        ScreenName = jt.user.screen_name,
                        Id = jt.id.ToString(),
                        ImageUri = "",
                        IsRetweet = jt.retweeted_status(),
                        NumericId = jt.id_str,
                        Published = DateTime.ParseExact(jt.created_at, "ddd MMM dd HH:mm:ss zzz yyyy", null), //"Wed Jul 03 22:05:32 +0000 2013"
                        Text = jt.text
                    };
                    if (tweet.IsRetweet)
                        tweet.OriginalAuthor = jt.retweeted_status.user.name;

                    lastId = tweet.NumericId;

                    Logger.Instance.Write(Environment.NewLine + "Received Tweet : {0}", tweet.Text);

                    if (queryUris.TweetMatches(tweet))
                        OnNewTweet(tweet);
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Write("Tweeter poll failed : {0}", ex);
            }
            finally
            {
                timer.Start();
            }
        }
 protected void OnNewTweet(Tweet t)
 {
     var handler = NewTweet;
     if (handler != null)
     {
         var e = new NewTweetEventArgs(t);
         handler(this, e);
     }
 }
 public NewTweetEventArgs(Tweet t)
 {
     Tweet = t;
 }
 public NewTweetEventArgs(Tweet t)
 {
     Tweet = t;
 }