public frmPrincipal(Twitterizer.OAuthTokens oauth_tokens) { //Construtor que recebe o Token do Twitterizer TOKEN = oauth_tokens; InitializeComponent(); }
public void StartStream(Twitterizer.Streaming.StreamOptions Streamopts) { Tweetstream = new Twitterizer.Streaming.TwitterStream(privOAuth.GetOAuthToken(), "o3o", Streamopts); Tweetstream.StartUserStream( new Twitterizer.Streaming.InitUserStreamCallback(FriendsCallback), new Twitterizer.Streaming.StreamStoppedCallback(StreamStoppedcallback), new Twitterizer.Streaming.StatusCreatedCallback(StatuscreatedCallback), new Twitterizer.Streaming.StatusDeletedCallback(statusdeletedCallback), new Twitterizer.Streaming.DirectMessageCreatedCallback(DMcreatedCallback), new Twitterizer.Streaming.DirectMessageDeletedCallback(DMDeletedtCallback), new Twitterizer.Streaming.EventCallback(eventCallback)); }
void StatusCreated(Twitterizer.TwitterStatus status) { string response = keywordResponder.Response(status.Text); if (!string.IsNullOrEmpty(response)) { client.Reply(status, response); } else { if (System.Text.RegularExpressions.Regex.IsMatch(status.Text, "^@meitanbot")) { client.Reply(status, replaceResponder.Response(null, status.User.Id)); } } }
public TweetExtended(Twitterizer.TwitterStatus st) { using (var db = new dbContainer()) { try { Local = db.TweetSet.First(t => t.TweetId == st.Id); } catch (InvalidOperationException) { Local = new Twitruc.DAL.Tweet(); Local.Content = st.Text; Local.AuthorNick = st.User.ScreenName; Local.Date = st.CreatedDate; Local.TweetId = st.Id; Local.TwitrucUser = null; Local.Public = !st.User.IsProtected; db.TweetSet.AddObject(Local); db.SaveChanges(); } Tweeter = st; EndInit(); } }
public static void Add(Twitterizer.TwitterSearchResult tweet) { using (CoffeeTweetDbContext db = new CoffeeTweetDbContext()) { var user = db.Users.SingleOrDefault(c => c.TwitterUserId == tweet.FromUserId.ToString()); if (user != null) { Coffee coffee = new Coffee { TweetId = tweet.Id.ToString(), User = tweet.FromUserId.ToString(), Text = tweet.Text, CreatedDate = tweet.CreatedDate }; db.Coffees.Add(coffee); } db.SaveChanges(); } }
void StreamStoppedcallback(Twitterizer.Streaming.StopReasons stopreason) { //What happen??!??!?!??!!??!1//1/1/111oneone //Restart dat SHEET OF PAPER //System.Threading.Thread.Sleep(2000); wat TwitterStatus notification = new TwitterStatus(); notification.Text = "Stream died! Restarting stream when twitter is aviable again..."; notification.User = new TwitterUser(); notification.User.ScreenName = "Internal message system"; NewTweet(notification, privOAuth); bool offline = true; while (offline) { bool isOnline = false; try { System.Net.NetworkInformation.Ping pong = new System.Net.NetworkInformation.Ping(); IPAddress adress = new IPAddress(new byte[] {8,8,8,8}); if (pong.Send(adress).Status == System.Net.NetworkInformation.IPStatus.Success) { System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping(); System.Net.NetworkInformation.PingReply result = ping.Send("www.twitter.com"); if (result.Status == System.Net.NetworkInformation.IPStatus.Success) { isOnline = true; } } } catch(Exception){} if (isOnline) { offline = false; } else { System.Threading.Thread.Sleep(10000); } } notification = new TwitterStatus(); notification.Text = "Restarting stream!"; notification.User = new TwitterUser(); notification.User.ScreenName = "Internal message system"; NewTweet(notification, privOAuth); System.Threading.Thread.Sleep(500); clear("connection lost"); FetchTweets(privOAuth); StartStream(new Twitterizer.Streaming.StreamOptions()); }
void statusdeletedCallback(Twitterizer.Streaming.TwitterStreamDeletedEvent deletedreason) { if(TweetDeleted != null) TweetDeleted(deletedreason); }
//Tweet stream stuff~! void FriendsCallback(Twitterizer.TwitterIdCollection input) { //Don't need this yet }
void eventCallback(Twitterizer.Streaming.TwitterStreamEvent eventstuff) { if (twitterevent != null) twitterevent(eventstuff); }
void DMDeletedtCallback(Twitterizer.Streaming.TwitterStreamDeletedEvent DeleteReason) { if (DMDeleted != null) DMDeleted(DeleteReason); }
void o3o_TweetDeleted(Twitterizer.Streaming.TwitterStreamDeletedEvent deletedreason) { //The calling thread cannot access this object because a different thread owns it. //foreach (TweetElement tweet in Mainwindow.TweetElements.Items) //{ // if (tweet.tweetElement.ID == deletedreason.Id.ToString()) // { // Mainwindow.TweetElements.Items.Remove(tweet); // } //} }
void o3o_TweetDeleted(Twitterizer.Streaming.TwitterStreamDeletedEvent deletedreason) { cheese = new DelTweetDelegate(deleteTweet); maindispatcher.Invoke(cheese, new object[] { deletedreason.Id.ToString() }); }
void StreamStoppedcallback(Twitterizer.Streaming.StopReasons stopreason) { //What happen??!??!?!??!!??!1//1/1/111oneone //Restart dat SHEET OF PAPER TwitterStatus notification = new TwitterStatus(); notification.Text = "Stream died! Restarting stream.. Poke a developer if this happens a lot, or get a better connection."; notification.User = new TwitterUser(); notification.User.ScreenName = "Internal message system"; NewTweet(notification, privOAuth); StartStream(new Twitterizer.Streaming.StreamOptions()); }