OSDN Git Service

140文字を越えるDMの投稿に対応
authorKimura Youichi <kim.upsilon@bucyou.net>
Sat, 15 Aug 2015 12:59:17 +0000 (21:59 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 15 Aug 2015 13:10:37 +0000 (22:10 +0900)
https://twittercommunity.com/t/41348

OpenTween.Tests/TwitterTest.cs
OpenTween/Api/TwitterConfiguration.cs
OpenTween/Resources/ChangeLog.txt
OpenTween/Twitter.cs

index b004f54..7d59eb8 100644 (file)
@@ -317,8 +317,12 @@ namespace OpenTween
         {
             using (var twitter = new Twitter())
             {
-                Assert.Equal(140, twitter.GetTextLengthRemain("D twitter "));
-                Assert.Equal(132, twitter.GetTextLengthRemain("D twitter hogehoge"));
+                // 2015年8月から DM の文字数上限が 10,000 文字に変更された
+                // https://twittercommunity.com/t/41348
+                twitter.Configuration.DmTextCharacterLimit = 10000;
+
+                Assert.Equal(10000, twitter.GetTextLengthRemain("D twitter "));
+                Assert.Equal(9992, twitter.GetTextLengthRemain("D twitter hogehoge"));
             }
         }
 
index adddfe1..6855d28 100644 (file)
@@ -58,6 +58,9 @@ namespace OpenTween.Api
         [DataMember(Name = "max_media_per_upload")]
         public int MaxMediaPerUpload { get; set; }
 
+        [DataMember(Name = "dm_text_character_limit")]
+        public int DmTextCharacterLimit { get; set; }
+
         /// <exception cref="SerializationException"/>
         public static TwitterConfiguration ParseJson(string json)
         {
@@ -75,6 +78,7 @@ namespace OpenTween.Api
                 ShortUrlLength = 19,
                 ShortUrlLengthHttps = 20,
                 PhotoSizeLimit = 3145728L,
+                DmTextCharacterLimit = 10000,
             };
         }
     }
index 35ba378..6057161 100644 (file)
@@ -1,6 +1,7 @@
 更新履歴
 
 ==== Ver 1.2.8-dev(2015/xx/xx)
+ * NEW: DMの文字数制限の緩和(上限10,000文字)に対応しました
  * FIX: 上下キーなどで選択ツイートを移動した直後に左右キーなどによる関連ツイートの移動が正しく動作しない不具合を修正
  * FIX: DM投稿時の「D (スクリーン名)」が文字数のカウントに余分に含まれていた不具合を修正
 
index afa1fe0..fd3d050 100644 (file)
@@ -3191,12 +3191,12 @@ namespace OpenTween
         {
             var matchDm = Twitter.DMSendTextRegex.Match(postText);
             if (matchDm.Success)
-                return this.GetTextLengthRemainInternal(matchDm.Groups["body"].Value);
+                return this.GetTextLengthRemainInternal(matchDm.Groups["body"].Value, isDm: true);
 
-            return this.GetTextLengthRemainInternal(postText);
+            return this.GetTextLengthRemainInternal(postText, isDm: false);
         }
 
-        private int GetTextLengthRemainInternal(string postText)
+        private int GetTextLengthRemainInternal(string postText, bool isDm)
         {
             var textLength = postText.Length;
 
@@ -3248,7 +3248,10 @@ namespace OpenTween
                 }
             }
 
-            return 140 - textLength;
+            if (isDm)
+                return this.Configuration.DmTextCharacterLimit - textLength;
+            else
+                return 140 - textLength;
         }
 
 #region "UserStream"