Exemple #1
0
 public void Post(string Tweet, TwitterStatus ReplyTo)
 {
     new Task(() =>
     {
         try
         {
             foreach (ExtendedOAuthTokens o in m.NowTokens)
             {
                 var t = TwitterStatus.Update(o.OAuthTokens, Tweet, new StatusUpdateOptions()
                 {
                     InReplyToStatusId = ReplyTo.Id
                 });
                 if (t.Result != RequestResult.Success)
                 {
                     if (t.Result == RequestResult.RateLimited)
                     {
                         MConsole.WriteLine(o.UserName + " has been RateLimited. ResetDate must be " + t.RateLimiting.ResetDate.ToString() + ".");
                     }
                     else
                     {
                         MConsole.WriteLine("Some error happened : " + t.ErrorMessage);
                     }
                 }
                 else
                 {
                     MConsole.WriteLine("Success to tweet as " + o.UserName + " " + Tweet);
                 }
             }
         }
         catch (Exception e)
         {
             MConsole.WriteLine("Some error happened : " + e.Message);
         }
     }).Start();
 }
Exemple #2
0
        void Event(TwitterStreamEvent e)
        {
            if (this.st == StartType.UserStream)
            {
                switch (e.EventType.ToString())
                {
                case "Favorite":
                    if (ExtendedOAuthTokens.Tokens.Any((x) => { return(x.UserName == e.Target.ScreenName); }))
                    {
                        MConsole.WriteLine(e.Source.ScreenName + " Favorited your tweet.");
                    }
                    break;

                case "Retweet":
                    if (ExtendedOAuthTokens.Tokens.Any((x) => { return(x.UserName == e.Target.ScreenName); }))
                    {
                        MConsole.WriteLine(e.Source.ScreenName + " Retweeted your tweet.");
                    }
                    break;

                case "Follow":
                    if (ExtendedOAuthTokens.Tokens.Any((x) => { return(x.UserName == e.Target.ScreenName); }))
                    {
                        MConsole.WriteLine(e.Source.ScreenName + " Followed you.");
                    }
                    break;
                }
            }
        }
Exemple #3
0
 public void Retweet(TwitterStatus t)
 {
     new Task(() =>
     {
         try
         {
             foreach (ExtendedOAuthTokens o in m.NowTokens)
             {
                 var f = TwitterStatus.Retweet(o.OAuthTokens, t.Id);
                 if (f.Result != RequestResult.Success)
                 {
                     if (f.Result == RequestResult.RateLimited)
                     {
                         MConsole.WriteLine(o.UserName + " has been RateLimited. ResetDate must be " + f.RateLimiting.ResetDate.ToString() + ".");
                     }
                     else
                     {
                         MConsole.WriteLine("Some error happened : " + f.ErrorMessage);
                     }
                 }
                 else
                 {
                     MConsole.WriteLine("Success to retweet [" + t.User.ScreenName + ": " + t.Text + "] as " + o.UserName);
                 }
             }
         }
         catch (Exception e)
         {
             MConsole.WriteLine("Some error happened : " + e.Message);
         }
     }).Start();
 }
Exemple #4
0
 void ActiveStatusViewColumnClick(object sender, ColumnClickEventArgs e)
 {
     ActiveStatus = null;
     ShowActiveStatus();
     Command       = "";
     PostText.Text = "";
     MConsole.WriteLine("Ready");
 }
Exemple #5
0
 private void UserViewButton_Click(object sender, EventArgs e)
 {
     if (ActiveStatus != null && NowTokens.Length != 0)
     {
         new UserView(ActiveStatus.User.ScreenName, NowTokens.First().OAuthTokens).Show();
     }
     else
     {
         MConsole.WriteLine("You haven't selected any accounts.");
     }
 }
Exemple #6
0
 public void MultiPoster(string[] Tweets)
 {
     new Task(() =>
     {
         try
         {
             foreach (ExtendedOAuthTokens o in m.NowTokens)
             {
                 foreach (string p in Tweets)
                 {
                     try
                     {
                         foreach (ExtendedOAuthTokens oo in m.NowTokens)
                         {
                             var t = TwitterStatus.Update(oo.OAuthTokens, p);
                             if (t.Result != RequestResult.Success)
                             {
                                 if (t.Result == RequestResult.RateLimited)
                                 {
                                     MConsole.WriteLine(o.UserName + " has been RateLimited. ResetDate must be " + t.RateLimiting.ResetDate.ToString() + ".");
                                 }
                                 else
                                 {
                                     MConsole.WriteLine("Some error happened : " + t.ErrorMessage);
                                 }
                             }
                         }
                     }
                     catch (Exception e)
                     {
                         MConsole.WriteLine("Some error happened : " + e.Message);
                     };
                 }
             }
         }
         catch (Exception e)
         {
             MConsole.WriteLine("Some error happened : " + e.Message);
         }
     }).Start();
 }
Exemple #7
0
 private bool CodeDo()
 {
     /*
      * //TEMP:
      * else if (PostText.Text == "/" || PostText.Text == "/")
      * {
      * return true;
      * }
      */
     if (PostText.Text == "/exit" || PostText.Text == "/e")
     {
         this.Close();
         return(true);
     }
     else if (PostText.Text == "/halt" || PostText.Text == "/h")
     {
         System.Environment.Exit(0);
         return(true);
     }
     else if (PostText.Text == "/account" || PostText.Text == "/a")
     {
         AccountManager m = new AccountManager(Accounts);
         m.ShowDialog();
         if (m.Change)
         {
             Accounts.Clear();
             AccountsList.Items.Clear();
             Accounts = AccountReader.Read("Settings/Accounts.dat");
             if (Accounts.Count != 0)
             {
                 AccountsList.Items.AddRange(Accounts.Keys.ToArray());
             }
         }
         return(true);
     }
     else if (PostText.Text == "/mariari" || PostText.Text == "/m")
     {
         twitterDo.MultiPoster(Mariari.Yakkai);
         return(true);
     }
     else if (PostText.Text == "/cannon" || PostText.Text == "/c")
     {
         twitterDo.MultiPoster(Mariari.Cannon);
         return(true);
     }
     else if (PostText.Text == "/stealth" || PostText.Text == "/s")
     {
         twitterDo.Post(Mariari.Stealth);
         return(true);
     }
     else if (PostText.Text == "/boss" || PostText.Text == "/b")
     {
         this.WindowState   = FormWindowState.Minimized;
         this.ShowInTaskbar = false;
         if (MessageBox.Show("上書きしますか?", "確認", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Cancel)
         {
             this.WindowState   = FormWindowState.Normal;
             this.ShowInTaskbar = true;
         }
         else
         {
             System.Environment.Exit(0);
         }
         return(true);
     }
     else if (PostText.Text.Contains("/user ") || PostText.Text.Contains("/u "))
     {
         if (NowTokens.Length != 0)
         {
             string view = PostText.Text.Replace("/user ", "").Replace("/u ", "");
             try
             {
                 new UserView(view, NowTokens.First().OAuthTokens).Show();
             }
             catch { }
         }
         else
         {
             MConsole.WriteLine("You haven't selected any accounts.");
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #8
0
 private void Status_Click(object sender, EventArgs e)
 {
     MConsole.Show();
 }
Exemple #9
0
        private void PostText_KeyPress(object sender, KeyPressEventArgs e)
        {
            int o;

            if (IsCommandMode && int.TryParse(e.KeyChar.ToString(), out o))
            {
                if (CommandCount == 0)
                {
                    try
                    {
                        ActivateStatus(o);
                        ShowActiveStatus();
                        IsCommandMode     = false;
                        PostText.ReadOnly = false;
                        CommandCount      = 0;
                        Command           = "";
                        PostText.Text     = "";
                        PostText.Text     = "@" + ActiveStatus.User.ScreenName + " ";
                        MConsole.WriteLine("Ctrl+F ... Favorite this Tweet. Ctrl+R ... Retweet this Tweet.");
                        CommandHandled = true;
                    }
                    catch
                    {
                        IsCommandMode     = false;
                        PostText.ReadOnly = false;
                        CommandCount      = 0;
                        MConsole.WriteLine("Ready");
                        Command       = "";
                        PostText.Text = "";
                    }
                }
                else
                {
                    Command += e.KeyChar;
                    MConsole.WriteLine("Command[" + Command + "]");
                    CommandCount++;
                }
            }
            else if (IsCommandMode && char.IsLetter(e.KeyChar))
            {
                Command += e.KeyChar;
                MConsole.WriteLine("Command[" + Command + "]");
                CommandCount++;
            }
            if (CommandCount >= 2)
            {
                if ((Command[0] == 'c' || Command[0] == 'C') && int.TryParse(Command[1].ToString(), out o))
                {
                    try
                    {
                        ActivateColumn(int.Parse(Command[1].ToString()));
                        IsCommandMode     = false;
                        PostText.ReadOnly = false;
                        CommandCount      = 0;
                        MConsole.WriteLine("Ready");
                        Command        = "";
                        PostText.Text  = "";
                        CommandHandled = true;
                    }
                    catch
                    {
                        IsCommandMode     = false;
                        PostText.ReadOnly = false;
                        CommandCount      = 0;
                        MConsole.WriteLine("Ready");
                        Command       = "";
                        PostText.Text = "";
                    }
                }
                else
                {
                    IsCommandMode     = false;
                    PostText.ReadOnly = false;
                    CommandCount      = 0;
                    MConsole.WriteLine("Ready");
                    Command       = "";
                    PostText.Text = "";
                }
            }
        }
Exemple #10
0
        private void PostText_KeyDown(object sender, KeyEventArgs e)
        {
            if (!IsCommandMode)
            {
                if (e.Control && e.KeyCode == Keys.Enter)
                {
                    if (CodeDo())
                    {
                        PostText.Text  = "";
                        CommandHandled = true;
                    }
                    else if (AccountsList.SelectedItems.Count != 0)
                    {
                        if (ActiveStatus == null)
                        {
                            twitterDo.Post(PostText.Text);
                            PostText.Text = "";
                        }
                        else
                        {
                            twitterDo.Post(PostText.Text, ActiveStatus);
                            PostText.Text = "";
                        }
                        Tweeted = true;
                    }
                    else
                    {
                        MConsole.WriteLine("You haven't selected any accounts.");
                    }
                }
                else if (e.Control && e.KeyCode == Keys.F)
                {
                    if (ActiveStatus != null)
                    {
                        twitterDo.Favorite(ActiveStatus);
                    }
                }
                else if (e.Control && e.KeyCode == Keys.R)
                {
                    if (ActiveStatus != null)
                    {
                        twitterDo.Retweet(ActiveStatus);
                    }
                }
                else if (e.Control && e.KeyCode == Keys.Q)
                {
                    if (ActiveStatus != null)
                    {
                        PostText.Text = "RT @" + ActiveStatus.User.ScreenName + ": " + ActiveStatus.Text;
                        PostText.Select(0, 0);
                    }
                }
                else if (e.Control && e.KeyCode == Keys.U)
                {
                    if (ActiveStatus != null && NowTokens.Length != 0)
                    {
                        new UserView(ActiveStatus.User.ScreenName, NowTokens.First().OAuthTokens).Show();
                    }
                    else
                    {
                        MConsole.WriteLine("You haven't selected any accounts.");
                    }
                }
                else if (e.Control && e.KeyCode == Keys.D)
                {
                    IsCommandMode = true;
                    PostText.Text = @"Command Mode
";
                    MConsole.WriteLine(ActiveColumn == null ? "c[Number] ... Activate the [Number]th column" : " [Number] ... Activate the [Number]th Tweet from Column that is activated");
                    PostText.ReadOnly = true;
                }
                else if (e.KeyCode == Keys.Delete)
                {
                    ActiveStatus = null;
                    ShowActiveStatus();
                    Command       = "";
                    PostText.Text = "";
                    MConsole.WriteLine("Ready");
                }
            }
            else
            {
                if (e.Control && e.KeyCode == Keys.D)
                {
                    IsCommandMode     = false;
                    PostText.ReadOnly = false;
                    CommandCount      = 0;
                    Command           = "";
                    PostText.Text     = "";
                }
            }
        }