Inheritance: OpenTween.OTBaseForm
Exemplo n.º 1
0
        public void CreateRetweetUnofficial_WithFormatterTest()
        {
            // TweetFormatterでHTMLに整形 → CreateRetweetUnofficialで復元 までの動作が正しく行えているか

            var text     = "#てすと @TwitterAPI \n http://t.co/KYi7vMZzRt";
            var entities = new TwitterEntity[]
            {
                new TwitterEntityHashtag
                {
                    Indices = new[] { 0, 4 },
                    Text    = "てすと",
                },
                new TwitterEntityMention
                {
                    Indices    = new[] { 5, 16 },
                    Id         = 6253282L,
                    Name       = "Twitter API",
                    ScreenName = "twitterapi",
                },
                new TwitterEntityUrl
                {
                    Indices     = new[] { 19, 41 },
                    DisplayUrl  = "twitter.com",
                    ExpandedUrl = "http://twitter.com/",
                    Url         = "http://t.co/KYi7vMZzRt",
                },
            };

            var html = TweetFormatter.AutoLinkHtml(text, entities);

            var expected = "#てすと @TwitterAPI " + Environment.NewLine + " http://twitter.com/";

            Assert.Equal(expected, TweenMain.CreateRetweetUnofficial(html, true));
        }
Exemplo n.º 2
0
        public void GetUrlFromDataObject_UnknownFormatTest()
        {
            using (var memstream = new MemoryStream(Array.Empty <byte>()))
            {
                var data = new DataObject("application/x-hogehoge", memstream);

                Assert.Throws <NotSupportedException>(() => TweenMain.GetUrlFromDataObject(data));
            }
        }
Exemplo n.º 3
0
        public UserInfoDialog(TweenMain mainForm, TwitterApi twitterApi)
        {
            this.mainForm   = mainForm;
            this.twitterApi = twitterApi;

            InitializeComponent();

            // LabelScreenName のフォントを OTBaseForm.GlobalFont に変更
            this.LabelScreenName.Font = this.ReplaceToGlobalFont(this.LabelScreenName.Font);
        }
Exemplo n.º 4
0
        public UserInfoDialog(TweenMain mainForm, Twitter twitter)
        {
            this.mainForm = mainForm;
            this.twitter = twitter;

            InitializeComponent();

            // LabelScreenName のフォントを OTBaseForm.GlobalFont に変更
            this.LabelScreenName.Font = this.ReplaceToGlobalFont(this.LabelScreenName.Font);
        }
Exemplo n.º 5
0
        public void GetUrlFromDataObject_UniformResourceLocatorWTest()
        {
            var dataBytes = Encoding.Unicode.GetBytes("https://twitter.com/\0");
            using (var memstream = new MemoryStream(dataBytes))
            {
                var data = new DataObject("UniformResourceLocatorW", memstream);

                var expected = ("https://twitter.com/", (string?)null);
                Assert.Equal(expected, TweenMain.GetUrlFromDataObject(data));
            }
        }
Exemplo n.º 6
0
        public void GetUrlFromDataObject_IESiteModeToUrlTest()
        {
            var dataBytes = Encoding.Unicode.GetBytes("https://twitter.com/\0Twitter\0");
            using (var memstream = new MemoryStream(dataBytes))
            {
                var data = new DataObject("IESiteModeToUrl", memstream);

                var expected = ("https://twitter.com/", "Twitter");
                Assert.Equal(expected, TweenMain.GetUrlFromDataObject(data));
            }
        }
Exemplo n.º 7
0
        public void GetUrlFromDataObject_XMozUrlTest()
        {
            var dataBytes = Encoding.Unicode.GetBytes("https://twitter.com/\nTwitter\0");

            using (var memstream = new MemoryStream(dataBytes))
            {
                var data = new DataObject("text/x-moz-url", memstream);

                var expected = new Tuple <string, string>("https://twitter.com/", "Twitter");
                Assert.Equal(expected, TweenMain.GetUrlFromDataObject(data));
            }
        }
Exemplo n.º 8
0
        public Thumbnail(TweenMain Owner)
        {
            this.Owner = Owner;

            Owner.PreviewScrollBar.Scroll += PreviewScrollBar_Scroll;
            Owner.PreviewPicture.MouseLeave += PreviewPicture_MouseLeave;
            Owner.PreviewPicture.DoubleClick += PreviewPicture_DoubleClick;

            ThumbnailServices = new[] {
                new ThumbnailService("ImgUr", ImgUr_GetUrl, ImgUr_CreateImage),
                new ThumbnailService("DirectLink", DirectLink_GetUrl, DirectLink_CreateImage),
                new ThumbnailService("TwitPic", TwitPic_GetUrl, TwitPic_CreateImage),
                new ThumbnailService("yfrog", yfrog_GetUrl, yfrog_CreateImage),
                new ThumbnailService("Plixi(TweetPhoto)", Plixi_GetUrl, Plixi_CreateImage),
                new ThumbnailService("MobyPicture", MobyPicture_GetUrl, MobyPicture_CreateImage),
                new ThumbnailService("携帯百景", MovaPic_GetUrl, MovaPic_CreateImage),
                new ThumbnailService("はてなフォトライフ", Hatena_GetUrl, Hatena_CreateImage),
                new ThumbnailService("PhotoShare/bctiny", PhotoShare_GetUrl, PhotoShare_CreateImage),
                new ThumbnailService("img.ly", imgly_GetUrl, imgly_CreateImage),
                new ThumbnailService("brightkite", brightkite_GetUrl, brightkite_CreateImage),
                new ThumbnailService("Twitgoo", Twitgoo_GetUrl, Twitgoo_CreateImage),
                new ThumbnailService("youtube", youtube_GetUrl, youtube_CreateImage),
                new ThumbnailService("ニコニコ動画", nicovideo_GetUrl, nicovideo_CreateImage),
                new ThumbnailService("ニコニコ静画", nicoseiga_GetUrl, nicoseiga_CreateImage),
                new ThumbnailService("Pixiv", Pixiv_GetUrl, Pixiv_CreateImage),
                new ThumbnailService("flickr", flickr_GetUrl, flickr_CreateImage),
                new ThumbnailService("フォト蔵", Photozou_GetUrl, Photozou_CreateImage),
                new ThumbnailService("TwitVideo", TwitVideo_GetUrl, TwitVideo_CreateImage),
                new ThumbnailService("Piapro", Piapro_GetUrl, Piapro_CreateImage),
                new ThumbnailService("Tumblr", Tumblr_GetUrl, Tumblr_CreateImage),
                new ThumbnailService("ついっぷるフォト", TwipplePhoto_GetUrl, TwipplePhoto_CreateImage),
                new ThumbnailService("mypix/shamoji", mypix_GetUrl, mypix_CreateImage),
                new ThumbnailService("ow.ly", Owly_GetUrl, Owly_CreateImage),
                new ThumbnailService("vimeo", Vimeo_GetUrl, Vimeo_CreateImage),
                new ThumbnailService("cloudfiles", CloudFiles_GetUrl, CloudFiles_CreateImage),
                new ThumbnailService("instagram", instagram_GetUrl, instagram_CreateImage),
                new ThumbnailService("pikubo", pikubo_GetUrl, pikubo_CreateImage),
                new ThumbnailService("PicPlz", PicPlz_GetUrl, PicPlz_CreateImage),
                new ThumbnailService("FourSquare", Foursquare_GetUrl, Foursquare_CreateImage),
                new ThumbnailService("TINAMI", Tinami_GetUrl, Tinami_CreateImage),
                new ThumbnailService("Twimg", Twimg_GetUrl, Twimg_CreateImage),
                new ThumbnailService("TwitrPix", TwitrPix_GetUrl, TwitrPix_CreateImage),
                new ThumbnailService("Pckles", Pckles_GetUrl, Pckles_CreateImage),
                new ThumbnailService("via.me", ViaMe_GetUrl, ViaMe_CreateImage),
            };
        }
Exemplo n.º 9
0
        private void FilterTextBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            TweenMain main = (TweenMain)this.Owner;
            TextBox   tbox = (TextBox)sender;

            if (e.KeyChar == '@')
            {
                //if (!SettingDialog.UseAtIdSupplement) return;
                //@マーク
                main.ShowSuplDialog(tbox, main.AtIdSupl);
                e.Handled = true;
            }
            else if (e.KeyChar == '#')
            {
                //if (!SettingDialog.UseHashSupplement) return;
                main.ShowSuplDialog(tbox, main.HashSupl);
                e.Handled = true;
            }
        }
Exemplo n.º 10
0
 private void FilterTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Space && e.Modifiers == (Keys.Shift | Keys.Control))
     {
         TweenMain main = (TweenMain)this.Owner;
         TextBox   tbox = (TextBox)sender;
         if (tbox.SelectionStart > 0)
         {
             int    endidx   = tbox.SelectionStart - 1;
             string startstr = "";
             for (int i = tbox.SelectionStart - 1; i >= 0; i--)
             {
                 char c = tbox.Text[i];
                 if (Char.IsLetterOrDigit(c) || c == '_')
                 {
                     continue;
                 }
                 if (c == '@')
                 {
                     startstr = tbox.Text.Substring(i + 1, endidx - i);
                     main.ShowSuplDialog(tbox, main.AtIdSupl, startstr.Length + 1, startstr);
                 }
                 else if (c == '#')
                 {
                     startstr = tbox.Text.Substring(i + 1, endidx - i);
                     main.ShowSuplDialog(tbox, main.HashSupl, startstr.Length + 1, startstr);
                 }
                 else
                 {
                     break;
                 }
             }
             e.Handled = true;
         }
     }
 }
Exemplo n.º 11
0
 public void ShowDraftWindow(string msg, string tweet, long reply_to, FileInfo mediaFile, TweenMain owner, bool retryAllowed)
 {
     Thread m = new Thread(() =>
     {
         TweetPool tweetRetry = new TweetPool();
         this.tweetPoolList.Add(tweetRetry);
         tweetRetry.Set(msg, tweet, reply_to, mediaFile, this, owner._cfgCommon.AutoRetryInterval);
         tweetRetry.MainForm = owner;
         tweetRetry.RetryAllowed = retryAllowed; // アカウント切り替え時自動再試行
         tweetRetry.ShowDialog();
     });
     m.Start();
 }
Exemplo n.º 12
0
        public void CreateRetweetUnofficial_SingleLineTest()
        {
            var statusText = "123<br>456<br>789";

            Assert.Equal("123 456 789", TweenMain.CreateRetweetUnofficial(statusText, false));
        }
Exemplo n.º 13
0
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            bool isBlankMatch   = false;
            bool isBlankExclude = false;

            //入力チェック
            if (!CheckMatchRule(out isBlankMatch) || !CheckExcludeRule(out isBlankExclude))
            {
                return;
            }
            if (isBlankMatch && isBlankExclude)
            {
                MessageBox.Show(Properties.Resources.ButtonOK_ClickText1, Properties.Resources.ButtonOK_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            int i = ListFilters.SelectedIndex;

            PostFilterRule ft;

            if (_mode == EDITMODE.AddNew)
            {
                ft = new PostFilterRule();
            }
            else
            {
                ft = (PostFilterRule)this.ListFilters.SelectedItem;
            }

            ft.MoveMatches = OptMove.Checked;
            ft.MarkMatches = CheckMark.Checked;

            string bdy = "";

            if (RadioAND.Checked)
            {
                ft.FilterName = UID.Text;
                TweenMain owner = (TweenMain)this.Owner;
                int       cnt   = owner.AtIdSupl.ItemCount;
                owner.AtIdSupl.AddItem("@" + ft.FilterName);
                if (cnt != owner.AtIdSupl.ItemCount)
                {
                    owner.ModifySettingAtId = true;
                }
                ft.UseNameField = true;
                bdy             = MSG1.Text;
            }
            else
            {
                ft.FilterName   = "";
                ft.UseNameField = false;
                bdy             = MSG2.Text;
            }
            ft.FilterSource = TextSource.Text;

            if (CheckRegex.Checked || CheckLambda.Checked)
            {
                ft.FilterBody = new[] { bdy };
            }
            else
            {
                ft.FilterBody = bdy.Split(' ', ' ')
                                .Where(x => !string.IsNullOrEmpty(x))
                                .ToArray();
            }

            ft.UseRegex      = CheckRegex.Checked;
            ft.FilterByUrl   = CheckURL.Checked;
            ft.CaseSensitive = CheckCaseSensitive.Checked;
            ft.FilterRt      = CheckRetweet.Checked;
            ft.UseLambda     = CheckLambda.Checked;

            bdy = "";
            if (RadioExAnd.Checked)
            {
                ft.ExFilterName   = ExUID.Text;
                ft.ExUseNameField = true;
                bdy = ExMSG1.Text;
            }
            else
            {
                ft.ExFilterName   = "";
                ft.ExUseNameField = false;
                bdy = ExMSG2.Text;
            }
            ft.ExFilterSource = TextExSource.Text;

            if (CheckExRegex.Checked || CheckExLambDa.Checked)
            {
                ft.ExFilterBody = new[] { bdy };
            }
            else
            {
                ft.ExFilterBody = bdy.Split(' ', ' ')
                                  .Where(x => !string.IsNullOrEmpty(x))
                                  .ToArray();
            }

            ft.ExUseRegex      = CheckExRegex.Checked;
            ft.ExFilterByUrl   = CheckExURL.Checked;
            ft.ExCaseSensitive = CheckExCaseSensitive.Checked;
            ft.ExFilterRt      = CheckExRetweet.Checked;
            ft.ExUseLambda     = CheckExLambDa.Checked;

            if (_mode == EDITMODE.AddNew)
            {
                if (!_sts.Tabs[ListTabs.SelectedItem.ToString()].AddFilter(ft))
                {
                    MessageBox.Show(Properties.Resources.ButtonOK_ClickText4, Properties.Resources.ButtonOK_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }

            SetFilters(ListTabs.SelectedItem.ToString());
            ListFilters.SelectedIndex = -1;
            if (_mode == EDITMODE.AddNew)
            {
                ListFilters.SelectedIndex = ListFilters.Items.Count - 1;
            }
            else
            {
                ListFilters.SelectedIndex = i;
            }
            _mode = EDITMODE.None;

            if (_directAdd)
            {
                this.Close();
            }
        }
Exemplo n.º 14
0
        private void ShowUserInfo_Load(object sender, EventArgs e)
        {
            MyOwner = (TweenMain)this.Owner;
            if ( !AnalizeUserInfo( userInfo ) ) {
                MessageBox.Show( Properties.Resources.ShowUserInfo1 );
                this.Close();
                return;
            }

            //アイコンロード
            BackgroundWorkerImageLoader.RunWorkerAsync();

            InitPath();
            InitTooltip();
            this.Text = this.Text.Insert( 0, _info.ScreenName + " " );
            LabelId.Text = _info.Id.ToString();
            LabelScreenName.Text = _info.ScreenName;
            LabelName.Text = _info.Name;

            LabelLocation.Text = _info.Location;

            SetLinklabelWeb( _info.Url );

            DescriptionBrowser.Visible = false;
            MakeDescriptionBrowserText( _info.Description );

            RecentPostBrowser.Visible = false;
            if ( _info.RecentPost != null ) {
                recentPostTxt = MyOwner.createDetailHtml(
                     MyOwner.TwitterInstance.CreateHtmlAnchor( ref _info.RecentPost, atlist, userInfo.Status.Entities, null ) +
                     " Posted at " + _info.PostCreatedAt.ToString() +
                     " via " + _info.PostSource );
            }

            LinkLabelFollowing.Text = _info.FriendsCount.ToString();
            LinkLabelFollowers.Text = _info.FollowersCount.ToString();
            LinkLabelFav.Text = _info.FavoriteCount.ToString();
            LinkLabelTweet.Text = _info.StatusesCount.ToString();

            LabelCreatedAt.Text = _info.CreatedAt.ToString();

            if ( _info.Protect )
                LabelIsProtected.Text = Properties.Resources.Yes;
            else
                LabelIsProtected.Text = Properties.Resources.No;

            if ( _info.Verified )
                LabelIsVerified.Text = Properties.Resources.Yes;
            else
                LabelIsVerified.Text = Properties.Resources.No;

            if ( MyOwner.TwitterInstance.Username == _info.ScreenName ) {
                ButtonEdit.Enabled = true;
                ChangeIconToolStripMenuItem.Enabled = true;
                ButtonBlock.Enabled = false;
                ButtonReportSpam.Enabled = false;
                ButtonBlockDestroy.Enabled = false;
            } else {
                ButtonEdit.Enabled = false;
                ChangeIconToolStripMenuItem.Enabled = false;
                ButtonBlock.Enabled = true;
                ButtonReportSpam.Enabled = true;
                ButtonBlockDestroy.Enabled = true;
            }
        }
Exemplo n.º 15
0
        public void CreateRetweetUnofficial_MentionTest()
        {
            var statusText = "<a class=\"mention\" href=\"https://twitter.com/twitterapi\">@TwitterAPI</a>";

            Assert.Equal("@TwitterAPI", TweenMain.CreateRetweetUnofficial(statusText, false));
        }
Exemplo n.º 16
0
        //TweitterPhotoのみ
        public string PostStatusRetry(string tweet, long reply_to, bool isDraft, TweenMain owner, FileInfo mediaFile = null)
        {
            if (isDraft)
            {
                ShowDraftWindow("ツイートは保留されています", tweet, reply_to, mediaFile, owner);
                return "Skip: ツイートは保留されています";
            }
            string ret;
            if (mediaFile == null)
            {
                ret = this.PostStatus(tweet, reply_to);
            }
            else
            {
                ret = this.PostStatusWithMedia(tweet, reply_to, mediaFile);
            }

            if (ret.StartsWith("Skip:"))
            {
                ShowDraftWindow(ret, tweet, reply_to, mediaFile, owner);
            }
            return ret;
        }
Exemplo n.º 17
0
 public void ShowDraftWindow(string msg, string tweet, long reply_to, FileInfo mediaFile, TweenMain owner)
 {
     Thread m = new Thread(() =>
     {
         TweetPool tweetRetry = new TweetPool();
         tweetRetry.Set(msg, tweet, reply_to, mediaFile, this);
         tweetRetry.mainForm = owner;
         tweetRetry.ShowDialog();
     });
     m.Start();
 }
Exemplo n.º 18
0
        public void CreateRetweetUnofficial_UrlTest()
        {
            var statusText = "<a href=\"http://t.co/KYi7vMZzRt\" title=\"http://twitter.com/\">twitter.com</a>";

            Assert.Equal("http://twitter.com/", TweenMain.CreateRetweetUnofficial(statusText, false));
        }
Exemplo n.º 19
0
        public string Upload(ref string filePath, ref string message, long reply_to, bool isDraft, TweenMain owner)
        {
            if ( string.IsNullOrEmpty( filePath ) )
                return "Err:File isn't specified.";

            if ( string.IsNullOrEmpty( message ) )
                message =  "";

            FileInfo mediaFile;
            try
            {
                mediaFile = new FileInfo( filePath );
            }
            catch ( NotSupportedException ex )
            {
                return "Err:" + ex.Message;
            }

            if ( !mediaFile.Exists )
                return "Err:File isn't exists.";

            if ( MyCommon.IsAnimatedGif( filePath ) )
                return "Err:Don't support animatedGIF.";

            return tw.PostStatusRetry(message, reply_to, isDraft, owner, mediaFile);
        }
Exemplo n.º 20
0
 public void TextContainsOnlyMentions_Test(string input, bool expected)
 => Assert.Equal(expected, TweenMain.TextContainsOnlyMentions(input));
Exemplo n.º 21
0
        public string PostStatusRetry(string tweet, long reply_to, bool isDraft, TweenMain owner, FileInfo mediaFile = null)
        {
            if (isDraft)
            {
                ShowDraftWindow("ツイートは保留されています", tweet, reply_to, mediaFile, owner, false);
                return "Skip: ツイートは保留されています";
            }
            string ret;
            if (mediaFile == null)
            {
                ret = this.PostStatus(tweet, reply_to);
            }
            else
            {
                ret = this.PostStatusWithMedia(tweet, reply_to, mediaFile);
            }

            if (ret.StartsWith("Skip:"))
            {
                if (ret.Contains("Status is a duplicate.")
                    && owner._cfgCommon.AutoAddZenkakuSpace
                    && (tweet + " ").Length <= 140 - (mediaFile == null ? 0 : 21))
                {
                    // 自動リトライ
                    return this.PostStatusRetry(tweet + " ", reply_to, false, owner, mediaFile);
                }
                else
                {
                    ShowDraftWindow(ret, tweet, reply_to, mediaFile, owner, true);
                }
            }
            return ret;
        }
Exemplo n.º 22
0
        public string Upload(ref string filePath, ref string message, long reply_to, bool isDraft, TweenMain owner)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return("Err:File isn't specified.");
            }
            if (string.IsNullOrEmpty(message))
            {
                message = "";
            }

            FileInfo mediaFile;

            try
            {
                mediaFile = new FileInfo(filePath);
            }
            catch (NotSupportedException ex)
            {
                return("Err:" + ex.Message);
            }
            if (mediaFile == null || !mediaFile.Exists)
            {
                return("Err:File isn't exists.");
            }

            string         content = "";
            HttpStatusCode ret;

            // img.lyへの投稿
            try
            {
                ret = this.UploadFile(mediaFile, message, ref content);
            }
            catch (Exception ex)
            {
                return("Err:" + ex.Message);
            }

            string url = "";

            if (ret == HttpStatusCode.OK)
            {
                XmlDocument xd = new XmlDocument();
                try
                {
                    xd.LoadXml(content);
                    // URLの取得
                    url = xd.SelectSingleNode("/image/url").InnerText;
                }
                catch (XmlException ex)
                {
                    return("Err:" + ex.Message);
                }
                catch (Exception ex)
                {
                    return("Err:" + ex.Message);
                }
            }
            else
            {
                return("Err:" + ret.ToString());
            }
            // アップロードまでは成功
            filePath = "";
            if (string.IsNullOrEmpty(url))
            {
                url = "";
            }
            // Twitterへの投稿
            // 投稿メッセージの再構成
            if (string.IsNullOrEmpty(message))
            {
                message = "";
            }
            if (message.Length + AppendSettingDialog.Instance.TwitterConfiguration.CharactersReservedPerMedia + 1 > 140)
            {
                message = message.Substring(0, 140 - AppendSettingDialog.Instance.TwitterConfiguration.CharactersReservedPerMedia - 1) + " " + url;
            }
            else
            {
                message += " " + url;
            }

            return(tw.PostStatusRetry(message, reply_to, isDraft, owner));
        }
Exemplo n.º 23
0
        private void ShowUserInfo_Load(object sender, EventArgs e)
        {
            MyOwner = (TweenMain)this.Owner;
            if (!AnalizeUserInfo(userInfo))
            {
                MessageBox.Show(Properties.Resources.ShowUserInfo1);
                this.Close();
                return;
            }

            //アイコンロード
            BackgroundWorkerImageLoader.RunWorkerAsync();

            InitPath();
            InitTooltip();
            this.Text            = this.Text.Insert(0, _info.ScreenName + " ");
            LabelId.Text         = _info.Id.ToString();
            LabelScreenName.Text = _info.ScreenName;
            LabelName.Text       = _info.Name;

            LabelLocation.Text = _info.Location;

            SetLinklabelWeb(_info.Url);

            DescriptionBrowser.Visible = false;
            MakeDescriptionBrowserText(_info.Description);

            RecentPostBrowser.Visible = false;
            if (_info.RecentPost != null)
            {
                recentPostTxt = MyOwner.createDetailHtml(
                    MyOwner.TwitterInstance.CreateHtmlAnchor(ref _info.RecentPost, atlist, userInfo.Status.Entities, null) +
                    " Posted at " + _info.PostCreatedAt.ToString() +
                    " via " + _info.PostSource);
            }

            LinkLabelFollowing.Text = _info.FriendsCount.ToString();
            LinkLabelFollowers.Text = _info.FollowersCount.ToString();
            LinkLabelFav.Text       = _info.FavoriteCount.ToString();
            LinkLabelTweet.Text     = _info.StatusesCount.ToString();

            LinkLabelListed.Text = _info.ListedCount.ToString();

            LabelCreatedAt.Text = _info.CreatedAt.ToString();

            if (_info.Protect)
            {
                LabelIsProtected.Text = Properties.Resources.Yes;
            }
            else
            {
                LabelIsProtected.Text = Properties.Resources.No;
            }

            if (_info.Verified)
            {
                LabelIsVerified.Text = Properties.Resources.Yes;
            }
            else
            {
                LabelIsVerified.Text = Properties.Resources.No;
            }

            if (MyOwner.TwitterInstance.Username == _info.ScreenName)
            {
                ButtonEdit.Enabled = true;
                ChangeIconToolStripMenuItem.Enabled = true;
                ButtonBlock.Enabled        = false;
                ButtonReportSpam.Enabled   = false;
                ButtonBlockDestroy.Enabled = false;
            }
            else
            {
                ButtonEdit.Enabled = false;
                ChangeIconToolStripMenuItem.Enabled = false;
                ButtonBlock.Enabled        = true;
                ButtonReportSpam.Enabled   = true;
                ButtonBlockDestroy.Enabled = true;
            }
        }
Exemplo n.º 24
0
        public void CreateRetweetUnofficial_HashtagTest()
        {
            var statusText = "<a class=\"hashtag\" href=\"https://twitter.com/search?q=%23OpenTween\">#OpenTween</a>";

            Assert.Equal("#OpenTween", TweenMain.CreateRetweetUnofficial(statusText, false));
        }
Exemplo n.º 25
0
        public string Upload(ref string filePath, ref string message, long reply_to, bool isDraft, TweenMain owner)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return("Err:File isn't specified.");
            }

            if (string.IsNullOrEmpty(message))
            {
                message = "";
            }

            FileInfo mediaFile;

            try
            {
                mediaFile = new FileInfo(filePath);
            }
            catch (NotSupportedException ex)
            {
                return("Err:" + ex.Message);
            }

            if (!mediaFile.Exists)
            {
                return("Err:File isn't exists.");
            }

            if (MyCommon.IsAnimatedGif(filePath))
            {
                return("Err:Don't support animatedGIF.");
            }

            return(tw.PostStatusRetry(message, reply_to, isDraft, owner, mediaFile));
        }
Exemplo n.º 26
0
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            bool isBlankMatch   = false;
            bool isBlankExclude = false;

            //入力チェック
            if (!CheckMatchRule(out isBlankMatch) || !CheckExcludeRule(out isBlankExclude))
            {
                return;
            }
            if (isBlankMatch && isBlankExclude)
            {
                MessageBox.Show(Properties.Resources.ButtonOK_ClickText1, Properties.Resources.ButtonOK_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            int          i = ListFilters.SelectedIndex;
            FiltersClass ft;

            ft = new FiltersClass();

            ft.MoveFrom = OptMove.Checked;
            ft.SetMark  = CheckMark.Checked;

            string bdy = "";

            if (RadioAND.Checked)
            {
                ft.NameFilter = UID.Text;
                TweenMain owner = (TweenMain)this.Owner;
                int       cnt   = owner.AtIdSupl.ItemCount;
                owner.AtIdSupl.AddItem("@" + ft.NameFilter);
                if (cnt != owner.AtIdSupl.ItemCount)
                {
                    owner.ModifySettingAtId = true;
                }
                ft.SearchBoth = true;
                bdy           = MSG1.Text;
            }
            else
            {
                ft.NameFilter = "";
                ft.SearchBoth = false;
                bdy           = MSG2.Text;
            }
            ft.Source = TextSource.Text.Trim();

            if (CheckRegex.Checked || CheckLambda.Checked)
            {
                ft.BodyFilter.Add(bdy);
            }
            else
            {
                string[] bf = bdy.Trim().Split((char)32);
                foreach (string bfs in bf)
                {
                    if (!string.IsNullOrEmpty(bfs))
                    {
                        ft.BodyFilter.Add(bfs.Trim());
                    }
                }
            }

            ft.UseRegex      = CheckRegex.Checked;
            ft.SearchUrl     = CheckURL.Checked;
            ft.CaseSensitive = CheckCaseSensitive.Checked;
            ft.IsRt          = CheckRetweet.Checked;
            ft.UseLambda     = CheckLambda.Checked;

            bdy = "";
            if (RadioExAnd.Checked)
            {
                ft.ExNameFilter = ExUID.Text;
                ft.ExSearchBoth = true;
                bdy             = ExMSG1.Text;
            }
            else
            {
                ft.ExNameFilter = "";
                ft.ExSearchBoth = false;
                bdy             = ExMSG2.Text;
            }
            ft.ExSource = TextExSource.Text.Trim();

            if (CheckExRegex.Checked || CheckExLambDa.Checked)
            {
                ft.ExBodyFilter.Add(bdy);
            }
            else
            {
                string[] bf = bdy.Trim().Split((char)32);
                foreach (string bfs in bf)
                {
                    if (!string.IsNullOrEmpty(bfs))
                    {
                        ft.ExBodyFilter.Add(bfs.Trim());
                    }
                }
            }

            ft.ExUseRegex      = CheckExRegex.Checked;
            ft.ExSearchUrl     = CheckExURL.Checked;
            ft.ExCaseSensitive = CheckExCaseSensitive.Checked;
            ft.IsExRt          = CheckExRetweet.Checked;
            ft.ExUseLambda     = CheckExLambDa.Checked;

            if (_mode == EDITMODE.AddNew)
            {
                if (!_sts.Tabs[ListTabs.SelectedItem.ToString()].AddFilter(ft))
                {
                    MessageBox.Show(Properties.Resources.ButtonOK_ClickText4, Properties.Resources.ButtonOK_ClickText2, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                _sts.Tabs[ListTabs.SelectedItem.ToString()].EditFilter((FiltersClass)ListFilters.SelectedItem, ft);
            }

            SetFilters(ListTabs.SelectedItem.ToString());
            ListFilters.SelectedIndex = -1;
            if (_mode == EDITMODE.AddNew)
            {
                ListFilters.SelectedIndex = ListFilters.Items.Count - 1;
            }
            else
            {
                ListFilters.SelectedIndex = i;
            }
            _mode = EDITMODE.None;

            if (_directAdd)
            {
                this.Close();
            }
        }
Exemplo n.º 27
0
        public void CreateRetweetUnofficial_MultiLineTest()
        {
            var statusText = "123<br>456<br>789";

            Assert.Equal("123" + Environment.NewLine + "456" + Environment.NewLine + "789", TweenMain.CreateRetweetUnofficial(statusText, true));
        }
Exemplo n.º 28
0
        public string Upload( ref string filePath, ref string message, long reply_to, bool isDraft, TweenMain owner )
        {
            if ( string.IsNullOrEmpty( filePath ) )
                return "Err:File isn't specified.";
            if ( string.IsNullOrEmpty( message ) )
                message = "";
            FileInfo mediaFile;
            try
            {
                mediaFile = new FileInfo( filePath );
            }
            catch ( NotSupportedException ex )
            {
                return "Err:" + ex.Message;
            }
            if ( mediaFile == null || !mediaFile.Exists )
                return "Err:File isn't exists.";

            string content = "";
            HttpStatusCode ret;
            // Plixiへの投稿
            try
            {
                ret = this.UploadFile( mediaFile, message, ref content );
            }
            catch ( Exception ex )
            {
                return "Err:" + ex.Message;
            }
            string url = "";
            if ( ret == HttpStatusCode.Created )
            {
                XmlDocument xd = new XmlDocument();
                try
                {
                    xd.LoadXml( content );
                    // MediaUrlの取得
                    url = xd.ChildNodes.Item( 0 ).ChildNodes[ 2 ].InnerText;
                }
                catch ( XmlException ex )
                {
                    return "Err:" + ex.Message;
                }
                catch ( Exception ex )
                {
                    return "Err:" + ex.Message;
                }
            }
            else
            {
                return "Err:" + ret.ToString();
            }
            // アップロードまでは成功
            filePath = "";
            if ( string.IsNullOrEmpty( url ) )
                url = "";
            if ( string.IsNullOrEmpty( message ) )
                message = "";
            // Twitterへの投稿
            // 投稿メッセージの再構成
            if ( message.Length + AppendSettingDialog.Instance.TwitterConfiguration.CharactersReservedPerMedia + 1 > 140 )
                message = message.Substring( 0, 140 - AppendSettingDialog.Instance.TwitterConfiguration.CharactersReservedPerMedia - 1 ) + " " + url;
            else
                message += " " + url;
            return tw.PostStatusRetry( message, reply_to, isDraft, owner );
        }
Exemplo n.º 29
0
        public void CreateRetweetUnofficial_DecodeTest()
        {
            var statusText = "&lt;&gt;&quot;&#39;&nbsp;";

            Assert.Equal("<>\"' ", TweenMain.CreateRetweetUnofficial(statusText, false));
        }