public void AddProfile() { ScreenDraw.Tweets.Clear(); ScreenDraw.Tweets.Refresh(); OAuthAccessToken userKey = new OAuthAccessToken(); OAuthRequestToken requestToken = User.Account.GetRequestToken(); Window auth = new Window(1, ScreenInfo.WindowWidth, 3, 0); Uri uri = User.Account.GetAuthorizationUri(requestToken); Process.Start(uri.ToString()); Curses.Echo = true; auth.Add("Please input the authentication number: "); auth.Refresh(); string verifier = auth.GetString(7); userKey = User.Account.GetAccessToken(requestToken, verifier); Profile newProfile = new Profile(); newProfile.Name = userKey.ScreenName; newProfile.UserKey = userKey.Token; newProfile.UserSecret = userKey.TokenSecret; if (ProfileExists(newProfile)) { ScreenDraw.ShowMessage("User already exists in the list"); } else { profiles.Add(newProfile); WriteFile(); ScreenDraw.ShowMessage("User added"); } Curses.Echo = false; auth.Dispose(); ScreenDraw draw = new ScreenDraw(); draw.ShowTimeline(); }
private void Mentions() { GetUpdates getMentions = new GetUpdates(); ScreenDraw draw = new ScreenDraw(); getMentions.GetMentions(); TimerMan.Pause(); draw.ShowMentions(); Actions twitterMethods = new Actions(); MentionsConsole(); if (Settings.AFK == false) { TimerMan.Resume(); } draw.ShowTimeline(); User.CounterConsoleWin.Refresh(); }
/// <summary> /// Deletes a specified tweet /// </summary> private void RemoveTweet(string command) { if (command.Split(' ')[1].Length != 2) { ScreenDraw.ShowMessage("Wrong syntax. Use /del [id]"); } else { long tweetID = (Int64)TweetIdentification.GetTweetID(command.Split(' ')[1]).InReplyToStatusId; InteractiveTweet tweet = TweetIdentification.FindTweet(tweetID); if (tweet.IsDirectMessage) { DeleteDirectMessageOptions delOpts = new DeleteDirectMessageOptions(); delOpts.Id = tweetID; } else { DeleteTweetOptions delOpts = new DeleteTweetOptions(); delOpts.Id = tweetID; User.Account.DeleteTweet(delOpts); } TwitterResponse result = User.Account.Response; if (result.Error == null) { GetUpdates.localTweetList.Remove(TweetIdentification.FindTweet(tweetID)); ScreenDraw.ShowMessage("Deleted"); ScreenDraw draw = new ScreenDraw(); draw.ShowTimeline(); User.CounterConsoleWin.Refresh(); } else { ScreenDraw.ShowMessage(result.Error.Code + ": " + result.Error.Message); } } }
private void Help() { ScreenDraw drawHelp = new ScreenDraw(); drawHelp.ShowHelp(); drawHelp.ShowTimeline(); }
/// <summary> /// Draws a tweet all fancy like in a box /// </summary> private void ShowTweet(string command) { /* This is still missing stuff, TODO! */ try /* Checks if the command was valid */ { bool exceptionTest = command.Split(' ')[1].StartsWith("@"); } catch (IndexOutOfRangeException) { ScreenDraw.ShowMessage("Wrong syntax. Use /tweet [id]"); return; } if (command.Split(' ')[1].Length != 2) { ScreenDraw.ShowMessage("Wrong syntax. Use /tweet [id]"); return; } else { long tweetID = Convert.ToInt64(TweetIdentification.GetTweetID(command.Split(' ')[1]).InReplyToStatusId); InteractiveTweet tweet = null; try { tweet = TweetIdentification.FindTweet(tweetID); } catch (KeyNotFoundException exIn) { ScreenDraw.ShowMessage(exIn.Message); return; } if (User.Account.Response.Error == null) { ScreenDraw tweetDrawer = new ScreenDraw(); tweetDrawer.DrawTweet(tweet); } else { ScreenDraw.ShowMessage(User.Account.Response.Error.Code + ": " + User.Account.Response.Error.Message); } } }
/// <summary> /// Accesses the profile of a user /// </summary> /// <param name="command">The entire command string</param> /// <returns></returns> private void ShowProfile(string command) { GetUserProfileForOptions profileOpts = new GetUserProfileForOptions(); string screenName = ""; try { bool exceptionTest = command.Split(' ')[1].StartsWith("@"); } catch (IndexOutOfRangeException) { ScreenDraw.ShowMessage("Wrong syntax. Use /profile [id] or /profile @[name]"); return; } if (command.Split(' ')[1].StartsWith("@")) { screenName = command.Split(' ')[1].Remove(0, 1); } else if (command.Split(' ')[1].Length != 2) { ScreenDraw.ShowMessage("Wrong syntax. Use /profile [id] or /profile @[name]"); return; } else { screenName = TweetIdentification.GetTweetID(command.Split(' ')[1]).Status; } profileOpts.ScreenName = screenName; TwitterUser profile = User.Account.GetUserProfileFor(profileOpts); ScreenDraw showProfile = new ScreenDraw(); if (GetUpdates.IsFollowing(screenName)) /* Because the profile object doesn't say this */ { ScreenDraw.IsFollowing = true; } else { ScreenDraw.IsFollowing = false; } if (GetUpdates.IsBlocked(screenName)) { ScreenDraw.IsBlocked = true; } else { ScreenDraw.IsBlocked = false; } if (User.Account.Response.Error == null) { showProfile.ShowUserProfile(profile); } else { ScreenDraw.ShowMessage(User.Account.Response.Error.Code + ": " + User.Account.Response.Error.Message); } return; }
/// <summary> /// Retweets a specified tweet /// </summary> private void Retweet(string command) { if (User.IsMissingArgs(command) == false) /* It's just an exception catching method, don't mind it */ { if (command.Split(' ')[1].Length != 2) { ScreenDraw.ShowMessage("Wrong syntax. Use /rt [id]"); } else { SendTweetOptions replyOpts = TweetIdentification.GetTweetID(command.Split(' ')[1]); RetweetOptions retweetOpts = new RetweetOptions(); long tweetID = Convert.ToInt64(replyOpts.InReplyToStatusId); retweetOpts.Id = tweetID; InteractiveTweet tweet = new InteractiveTweet(); try { tweet = TweetIdentification.FindTweet(tweetID); } catch (KeyNotFoundException exceptionInfo) { ScreenDraw.ShowMessage(exceptionInfo.Message); return; } if (tweet.IsDirectMessage) { ScreenDraw.ShowMessage("You can't retweet DMs, silly"); return; } User.Account.Retweet(retweetOpts); if (User.Account.Response.Error == null) { ScreenDraw.ShowMessage("Retweeted"); ScreenDraw redraw = new ScreenDraw(); redraw.ShowTimeline(); } else { ScreenDraw.ShowMessage(User.Account.Response.Error.Code + ": " + User.Account.Response.Error.Message); } } } }
public void Stream() { const int maxStreamEvents = 5; ScreenDraw draw = new ScreenDraw(); var block = new AutoResetEvent(false); var count = 0; User.Account.StreamUser((streamEvent, response) => { if (streamEvent is TwitterUserStreamEnd) { block.Set(); ScreenDraw.ShowMessage("Streaming is over"); } if (response.StatusCode == 0) { if (streamEvent is TwitterUserStreamEvent) { var @event = (TwitterUserStreamEvent)streamEvent; } if (streamEvent is TwitterUserStreamStatus) { CleanTweets(); var tweet = ((TwitterUserStreamStatus)streamEvent).Status; InteractiveTweet newStatus = ConvertTweet(tweet); if (localTweetList.Contains(newStatus) == false) { localTweetList.Insert(0, newStatus); if (TimerMan.Paused == false) { draw.ShowTimeline(); User.CounterConsoleWin.Refresh(); } } } if (streamEvent is TwitterUserStreamDirectMessage) { var dm = ((TwitterUserStreamDirectMessage)streamEvent).DirectMessage; localTweetList.Insert(0, ConvertDM(dm)); if (TimerMan.Paused == false) { draw.ShowTimeline(); User.CounterConsoleWin.Refresh(); } } if (streamEvent is TwitterUserStreamDeleteStatus) { var deleted = (TwitterUserStreamDeleteStatus)streamEvent; localTweetList.Remove(TweetIdentification.FindTweet(deleted.StatusId)); if (TimerMan.Paused == false) { draw.ShowTimeline(); User.CounterConsoleWin.Refresh(); } } if (streamEvent is TwitterUserStreamDeleteDirectMessage) { var deleted = (TwitterUserStreamDeleteDirectMessage)streamEvent; localTweetList.Remove(TweetIdentification.FindTweet(deleted.DirectMessageId)); if (TimerMan.Paused == false) { draw.ShowTimeline(); User.CounterConsoleWin.Refresh(); } } count++; if (count == maxStreamEvents) { block.Set(); } } else { ScreenDraw.ShowMessage("Could not start stream"); Environment.Exit(1); /* If it can't stream, that's it man */ } }); }