/// <summary> /// Converts a raw DM into an InteractiveTweet object /// </summary> private InteractiveTweet ConvertDM(TwitterDirectMessage message) { TweetIdentification create = new TweetIdentification(); if (message.Author.ScreenName != GetUpdates.userScreenName) { try { SoundPlayer notification = new SoundPlayer(); notification.SoundLocation = Environment.CurrentDirectory + "/notification.wav"; notification.Play(); } catch (Exception) { } } InteractiveTweet dm = new InteractiveTweet(); dm.AuthorScreenName = message.Author.ScreenName; dm.Contents = message.Text; dm.ID = message.Id; dm.IsDirectMessage = true; dm.TimePosted = message.CreatedDate; dm.TweetIdentification = create.GenerateIdentification(); return dm; }
/// <summary> /// Override for mentions only /// </summary> public InteractiveTweet ConvertTweet(TwitterStatus tweet, bool isMention) { if (isMention) { InteractiveTweet formedTweet = new InteractiveTweet(); /* Big block of filling the InteractiveTweet properties */ formedTweet.AuthorScreenName = "@" + tweet.Author.ScreenName; formedTweet.AuthorDisplayName = tweet.User.Name; formedTweet.AuthorDisplayName = tweet.User.Name; if (Settings.ShortLinks) { formedTweet.Contents = EscapeChars(tweet.Text); } else { formedTweet.Contents = tweet.Text; if (tweet.Entities.Urls.Count != 0) { foreach (var link in tweet.Entities.Urls) { if (link.ExpandedValue.Replace("http://", "").Replace("https://", "").Length <= ScreenInfo.WindowWidth - 8) { formedTweet.Contents = formedTweet.Contents.Replace(link.Value, link.ExpandedValue); formedTweet.Contents = formedTweet.Contents.Replace("http://", "").Replace("https://", ""); } } } if (tweet.Entities.Media.Count != 0) { foreach (var image in tweet.Entities.Media) { formedTweet.Contents = formedTweet.Contents.Replace(image.Url, image.DisplayUrl); } } formedTweet.Contents = EscapeChars(formedTweet.Contents); } formedTweet.ID = tweet.Id; TweetIdentification generateID = new TweetIdentification(); formedTweet.TweetIdentification = generateID.GenerateIdentification(); formedTweet.IsFavorited = tweet.IsFavorited; formedTweet.IsMention = true; formedTweet.LinkToTweet = @"https://twitter.com/" + tweet.Author.ScreenName + @"/status/" + tweet.Id; formedTweet.FavoriteCount = tweet.FavoriteCount; formedTweet.RetweetCount = tweet.RetweetCount; formedTweet.TimePosted = tweet.CreatedDate; if (formedTweet.Contents.Contains("@" + userScreenName) && formedTweet.IsMention == false) { try { SoundPlayer notification = new SoundPlayer(); notification.SoundLocation = Environment.CurrentDirectory + "/notification.wav"; notification.Play(); } catch (Exception) { } } return formedTweet; } else { return ConvertTweet(tweet); } }