public static void Executa(Tweetinvi.Core.Interfaces.ILoggedUser logado, TextReader leitor) { tweet = leitor; loggedUser = logado; aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); //Verificador do Timer. Quando o tempo tiver terminado, ele executada o evento OnTimedEvent. aTimer.Enabled = true; //Reseta o timer, para outra verificação. }
/// <summary> /// Create a new tweet from an original Tweetinvi object /// </summary> public Tweet(Tweetinvi.Core.Interfaces.ITweet original) { this.ID = original.Id; this.Text = original.Text.Replace(",", ""); this.Time = original.CreatedAt; this.Retweets = original.RetweetCount; this.Favourites = original.FavouriteCount; this.User = original.Creator.Name; this.Followers = original.Creator.FollowersCount; }
public void displayTweet(Tweetinvi.Core.Events.EventArguments.TweetEventArgs a) { if (a.Tweet.Creator.ProfileImageFullSizeUrl != "") { try { imgAvatar.Load(a.Tweet.Creator.ProfileImageFullSizeUrl); } catch (Exception) { try { imgAvatar.Load(a.Tweet.Creator.ProfileImageUrl); } catch (Exception) { imgAvatar.Image = imgAvatar.ErrorImage; } } } string tweetCreatorName = a.Tweet.Creator.Name; string tweetCreatorScreenName = "@" + a.Tweet.Creator.ScreenName; string tweetText = formatTweetText(a.Tweet.Text); bool boolDisplayPicture = false; if ((a.Tweet.Entities.Medias != null) && (a.Tweet.Entities.Medias.First().MediaType == "photo") && (a.Tweet.Entities.Medias.First().MediaURL != "")) { try { string strFirstMediaURL = a.Tweet.Entities.Medias.First().MediaURL; string strFirstMediaType = a.Tweet.Entities.Medias.First().MediaType; string strFirstURL = a.Tweet.Entities.Medias.First().URL; imgTweet.Load(strFirstMediaURL); tweetText = tweetText.Replace(strFirstURL, "").Trim(); boolDisplayPicture = true; } catch (Exception) { boolDisplayPicture = false; } } else { boolDisplayPicture = false; } lblName.Text = tweetCreatorName; lblScreenName.Text = tweetCreatorScreenName; txtTweet.Text = tweetText; imgTweet.Visible = boolDisplayPicture; }
void stream_JsonObjectReceived(object sender, Tweetinvi.Core.Events.EventArguments.JsonObjectEventArgs e) { try { string filename = DateTime.Now.ToString("yyyyMMdd") + ".log"; File.AppendAllText(filename, e.Json); Console.WriteLine(e.Json); } catch (Exception ex) { log.Error(ex, ex.Message); } }
private static void InsertFollower(Tweetinvi.Core.Interfaces.IUser follower) { using (var context = new ClientContext(Constants.URL)) { context.Credentials = new SharePointOnlineCredentials(Constants.User,GetPassSecure(Constants.Pass)); // Assume that the web has a list named "Announcements". List twitterList = context.Web.Lists.GetByTitle(Constants.ListTwitter); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem newItem = twitterList.AddItem(itemCreateInfo); newItem[Constants.FieldName] = follower.Name; newItem[Constants.FieldDescription] = follower.Description; newItem[Constants.FieldPhoto] = follower.ProfileImageFullSizeUrl; newItem.Update(); context.ExecuteQuery(); Console.WriteLine("Insertado el seguido:" + follower.Name); } }
private void filteredStream_MatchingTweetReceived(object sender, Tweetinvi.Core.Events.EventArguments.MatchedTweetReceivedEventArgs e) { if (e.MatchingTracks != null && e.MatchingTracks.Any()) { var offerts = listaCategorias .Where(x => !string.IsNullOrEmpty(x.value) && e.MatchingTracks.Contains(x.value, StringComparer.InvariantCultureIgnoreCase)); if (offerts != null && offerts.Any()) { foreach (var offert in offerts) { Random rnd = new Random(); var tweet = String.Format("{0};{1};{2};{3}", offert.value, e.Tweet.CreatedAt, listaProvincias[rnd.Next(0, listaProvincias.Count-1)].value, e.Tweet.Text); Console.WriteLine(tweet); AzureHelper.GuardarArchivoEnBlob(tweet, "demo/inputTweets2/" + Guid.NewGuid()); } } } }
private void OnMessageSent(object sender, Tweetinvi.Core.Events.EventArguments.MessageEventArgs e) { }
public void WriteTweet(Tweetinvi.Core.Interfaces.ITweet tweet) { lock(queue) { queue.Enqueue(tweet); } }
private void stream_MatchingTweetReceived(object sender, Tweetinvi.Core.Events.EventArguments.MatchedTweetReceivedEventArgs e) { Tweetinvi.Core.Interfaces.ITweet t = e.Tweet; foreach (KeyValuePair<string, List<string>> kp in this.follows) { string channel = kp.Key; List<string> tweeters = kp.Value; foreach (string tweeter in tweeters) { if (tweeter.ToLower() == t.Creator.ScreenName.ToLower()) { Host.PluginResponse(channel, String.Format("@{0} just tweeted: {1}", t.Creator.ScreenName, WebUtility.HtmlDecode(t.Text))); } } } }
void stream_MatchingTweetAndLocationReceived(object sender, Tweetinvi.Core.Events.EventArguments.MatchedTweetAndLocationReceivedEventArgs e) { //Console.WriteLine(e.Tweet); }
void stream_WarningFallingBehindDetected(object sender, Tweetinvi.Core.Events.EventArguments.WarningFallingBehindEventArgs e) { Host.PluginResponse(Host.PluginBotAdmin, "Twitter: Warning Falling Behind! " + e.WarningMessage.Message); }
private void twitterStream_MatchingTweetReceived(object sender, Tweetinvi.Core.Events.EventArguments.MatchedTweetReceivedEventArgs e) { string name = e.Tweet.Creator.ScreenName; string text = WebUtility.HtmlDecode(e.Tweet.Text); Regex hashMatch = new Regex(@"#\w+"); if (text.IndexOf("#") != -1) { MatchCollection matches = hashMatch.Matches(text); if (matches.Count > 0) { Host.PluginResponse(matches[0].Value, String.Format("@{0} tweets you: {1}", name, text)); } } else { Tweet.PublishTweet(String.Format("@{0}: Include the channel name as a hashtag!")); } }
private void OnTweetUnfavorited(object sender, Tweetinvi.Core.Events.EventArguments.TweetFavouritedEventArgs e) { }
private void OnTweetCreated(object sender, Tweetinvi.Core.Events.EventArguments.TweetReceivedEventArgs e) { //tweet created by anyone _owner.Dispatcher.Invoke(() => TimelineFeed.Add(Tweet.FromApi(e.Tweet))); }
void stream_DisconnectMessageReceived(object sender, Tweetinvi.Core.Events.EventArguments.DisconnectMessageEventArgs e) { InitFollow(); }
void OnStreamStopped(object sender, Tweetinvi.Core.Events.EventArguments.StreamExceptionEventArgs args) { if(args.Exception != null) { Thread.Sleep(5000); m_streamTask = m_stream.StartStreamMatchingAnyConditionAsync(); } }
void OnMatchingTweekReceived(object sender, Tweetinvi.Core.Events.EventArguments.MatchedTweetReceivedEventArgs args) { if(args.Tweet.Language == Tweetinvi.Core.Enum.Language.English || args.Tweet.Media.Count > 0) { Dispatcher.InvokeAsync(() => { if(!args.Tweet.Retweeted) { var images = new List<BitmapImage>(); images.Add(new BitmapImage(new Uri(args.Tweet.CreatedBy.ProfileImageUrl, UriKind.Absolute))); foreach(var m in args.Tweet.Media) { //if(m.MediaType == "photo") { images.Add(new BitmapImage(new Uri(m.MediaURL + ":thumb", UriKind.Absolute))); } } Dispatcher.InvokeAsync(() => CheckTweetData(args.Tweet.Text, images), DispatcherPriority.Background); } }); } }