Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
        /// <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);
                }

            }
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
 private void Help()
 {
     ScreenDraw drawHelp = new ScreenDraw();
     drawHelp.ShowHelp();
     drawHelp.ShowTimeline();
 }
Ejemplo n.º 5
0
        /// <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);
                    }

                }
            }
        }
Ejemplo n.º 6
0
        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 */
                }

            });
        }