+ /// 投稿時に auto_populate_reply_metadata オプションによって自動で追加されるメンションを除去します
+ /// </summary>
+ private string RemoveAutoPopuratedMentions(string statusText, out long[] autoPopulatedUserIds)
+ {
+ List<long> _autoPopulatedUserIds = new List<long>();
+
+ var replyToPost = this.inReplyTo != null ? this._statuses[this.inReplyTo.Item1] : null;
+ if (replyToPost != null)
+ {
+ if (statusText.StartsWith($"@{replyToPost.ScreenName} ", StringComparison.Ordinal))
+ {
+ statusText = statusText.Substring(replyToPost.ScreenName.Length + 2);
+ _autoPopulatedUserIds.Add(replyToPost.UserId);
+
+ foreach (var reply in replyToPost.ReplyToList)
+ {
+ if (statusText.StartsWith($"@{reply.Item2} ", StringComparison.Ordinal))
+ {
+ statusText = statusText.Substring(reply.Item2.Length + 2);
+ _autoPopulatedUserIds.Add(reply.Item1);
+ }
+ }
+ }
+ }
+
+ autoPopulatedUserIds = _autoPopulatedUserIds.ToArray();
+
+ return statusText;
+ }
+
+ /// <summary>
+ /// attachment_url に指定可能な URL が含まれていれば除去
+ /// </summary>
+ private string RemoveAttachmentUrl(string statusText, out string attachmentUrl)
+ {
+ attachmentUrl = null;
+
+ // attachment_url は media_id と同時に使用できない
+ if (this.ImageSelector.Visible && this.ImageSelector.SelectedService is TwitterPhoto)
+ return statusText;
+
+ var match = Twitter.AttachmentUrlRegex.Match(statusText);
+ if (!match.Success)
+ return statusText;
+
+ attachmentUrl = match.Value;
+
+ // マッチした URL を空白に置換
+ statusText = statusText.Substring(0, match.Index);
+
+ // テキストと URL の間にスペースが含まれていれば除去
+ return statusText.TrimEnd(' ');
+ }
+
+ private string FormatStatusTextExtended(string statusText)
+ {
+ long[] autoPopulatedUserIds;
+ string attachmentUrl;
+
+ return this.FormatStatusTextExtended(statusText, out autoPopulatedUserIds, out attachmentUrl);
+ }
+
+ /// <summary>
+ /// <see cref="FormatStatusText"/> に加えて、拡張モードで140字にカウントされない文字列の除去を行います
+ /// </summary>
+ private string FormatStatusTextExtended(string statusText, out long[] autoPopulatedUserIds, out string attachmentUrl)
+ {
+ statusText = this.RemoveAutoPopuratedMentions(statusText, out autoPopulatedUserIds);
+
+ statusText = this.RemoveAttachmentUrl(statusText, out attachmentUrl);
+
+ return this.FormatStatusText(statusText);
+ }
+
+ /// <summary>