• R/O
  • HTTP
  • SSH
  • HTTPS

open-tween: Commit

開発に使用するリポジトリ


Commit MetaInfo

Revisãobef06936aa7a2c6e251110d06984971238718672 (tree)
Hora2018-05-20 04:28:43
AutorKimura Youichi <kim.upsilon@bucy...>
CommiterKimura Youichi

Mensagem de Log

投稿欄にメンション以外の文字列が含まれていない場合は投稿時に警告ダイアログを表示する

Mudança Sumário

Diff

--- a/OpenTween.Tests/TweenMainTest.cs
+++ b/OpenTween.Tests/TweenMainTest.cs
@@ -165,5 +165,14 @@ namespace OpenTween
165165 var expected = "#てすと @TwitterAPI " + Environment.NewLine + " http://twitter.com/";
166166 Assert.Equal(expected, TweenMain.CreateRetweetUnofficial(html, true));
167167 }
168+
169+ [Theory]
170+ [InlineData("", true)]
171+ [InlineData("hoge", false)]
172+ [InlineData("@twitterapi ", true)]
173+ [InlineData("@twitterapi @opentween ", true)]
174+ [InlineData("@twitterapi @opentween hoge", false)]
175+ public void TextContainsOnlyMentions_Test(string input, bool expected)
176+ => Assert.Equal(expected, TweenMain.TextContainsOnlyMentions(input));
168177 }
169178 }
--- a/OpenTween/Properties/Resources.Designer.cs
+++ b/OpenTween/Properties/Resources.Designer.cs
@@ -1832,6 +1832,16 @@ namespace OpenTween.Properties {
18321832 }
18331833
18341834 /// <summary>
1835+ /// この内容で投稿してもよろしいですか?
1836+ ///{0} に類似しているローカライズされた文字列を検索します。
1837+ /// </summary>
1838+ internal static string PostConfirmText {
1839+ get {
1840+ return ResourceManager.GetString("PostConfirmText", resourceCulture);
1841+ }
1842+ }
1843+
1844+ /// <summary>
18351845 /// 投稿できる文字数の上限を越えています。強制的に投稿しますか? に類似しているローカライズされた文字列を検索します。
18361846 /// </summary>
18371847 internal static string PostLengthOverMessage1 {
--- a/OpenTween/Properties/Resources.en.resx
+++ b/OpenTween/Properties/Resources.en.resx
@@ -1158,4 +1158,8 @@ Existing setting files are copied to {1}.
11581158 <data name="UrlConvert_BitlyAuthRequired" xml:space="preserve">
11591159 <value>To use Bitly, you must perform the Bitly authentication in settings dialog.</value>
11601160 </data>
1161+ <data name="PostConfirmText" xml:space="preserve">
1162+ <value>Are you sure to you want to post this text?
1163+{0}</value>
1164+ </data>
11611165 </root>
\ No newline at end of file
--- a/OpenTween/Properties/Resources.resx
+++ b/OpenTween/Properties/Resources.resx
@@ -1216,4 +1216,8 @@
12161216 <data name="UrlConvert_BitlyAuthRequired" xml:space="preserve">
12171217 <value>Bitlyを使用するには設定画面で認証情報を入力する必要があります</value>
12181218 </data>
1219+ <data name="PostConfirmText" xml:space="preserve">
1220+ <value>この内容で投稿してもよろしいですか?
1221+{0}</value>
1222+ </data>
12191223 </root>
\ No newline at end of file
--- a/OpenTween/Resources/ChangeLog.txt
+++ b/OpenTween/Resources/ChangeLog.txt
@@ -3,6 +3,7 @@
33 ==== Ver 1.4.2-dev(xxxx/xx/xx)
44 * NEW: システムのタイムゾーンの変更を検知して、ツイートの投稿日時などの表示を新しいタイムゾーンに同期します
55 * NEW: 5月中旬に予定されている引用ツイートに関する Twitter API の仕様変更に対応
6+ * NEW: リプライ送信時にリプライ以外何も入力されていない状態であった場合は警告のダイアログを表示します
67 * FIX: 動画のサムネイル画像に「URLをコピー」を行うとエラーが発生する不具合を修正
78 * FIX: pic.twitter.com のサムネイル画像をHTTPS接続で取得するように修正
89
--- a/OpenTween/Tween.cs
+++ b/OpenTween/Tween.cs
@@ -2101,6 +2101,15 @@ namespace OpenTween
21012101 }
21022102 }
21032103
2104+ if (TextContainsOnlyMentions(this.StatusText.Text))
2105+ {
2106+ var message = string.Format(Properties.Resources.PostConfirmText, this.StatusText.Text);
2107+ var ret = MessageBox.Show(message, Application.ProductName, MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
2108+
2109+ if (ret != DialogResult.OK)
2110+ return;
2111+ }
2112+
21042113 var inReplyToStatusId = this.inReplyTo?.Item1;
21052114 var inReplyToScreenName = this.inReplyTo?.Item2;
21062115 _history[_history.Count - 1] = new StatusTextHistory(StatusText.Text, inReplyToStatusId, inReplyToScreenName);
@@ -4751,6 +4760,32 @@ namespace OpenTween
47514760 }
47524761
47534762 /// <summary>
4763+ /// メンション以外の文字列が含まれていないテキストであるか判定します
4764+ /// </summary>
4765+ internal static bool TextContainsOnlyMentions(string text)
4766+ {
4767+ var mentions = TweetExtractor.ExtractMentionEntities(text).OrderBy(x => x.Indices[0]);
4768+ var startIndex = 0;
4769+
4770+ foreach (var mention in mentions)
4771+ {
4772+ var textPart = text.Substring(startIndex, mention.Indices[0] - startIndex);
4773+
4774+ if (!string.IsNullOrWhiteSpace(textPart))
4775+ return false;
4776+
4777+ startIndex = mention.Indices[1];
4778+ }
4779+
4780+ var textPartLast = text.Substring(startIndex);
4781+
4782+ if (!string.IsNullOrWhiteSpace(textPartLast))
4783+ return false;
4784+
4785+ return true;
4786+ }
4787+
4788+ /// <summary>
47544789 /// 投稿時に auto_populate_reply_metadata オプションによって自動で追加されるメンションを除去します
47554790 /// </summary>
47564791 private string RemoveAutoPopuratedMentions(string statusText, out long[] autoPopulatedUserIds)
Show on old repository browser