diff options
author | Vitaly Takmazov | 2023-01-12 11:46:40 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-12 11:56:11 +0300 |
commit | e377357b00cdb151aa20d96a0ce7a5f1a8bbe9c9 (patch) | |
tree | 8e776a6705e71eb72e8ea48bb3d345bc0e96fa6c /src/main/java/com/juick/util/formatters | |
parent | 84f6e27f7e563bcb58815575546c52c944f0cd3e (diff) |
Telegram: parse_mode=html
Diffstat (limited to 'src/main/java/com/juick/util/formatters')
-rw-r--r-- | src/main/java/com/juick/util/formatters/PlainTextFormatter.java | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/main/java/com/juick/util/formatters/PlainTextFormatter.java b/src/main/java/com/juick/util/formatters/PlainTextFormatter.java index 83feb8a6..b1b1a44a 100644 --- a/src/main/java/com/juick/util/formatters/PlainTextFormatter.java +++ b/src/main/java/com/juick/util/formatters/PlainTextFormatter.java @@ -31,25 +31,20 @@ import java.util.Locale; public class PlainTextFormatter { static PrettyTime pt = new PrettyTime(new Locale("en")); - public static String formatPost(Message jmsg) { - return formatPost(jmsg, false); + public static String formatPost(Message jmsg, String domain) { + return formatPost(jmsg, false, domain); } - public static String formatPost(Message jmsg, boolean markdown) { + public static String formatPost(Message jmsg, boolean compatibleWithDurov, String domain) { StringBuilder sb = new StringBuilder(); String title = MessageUtils.isReply(jmsg) ? "Reply by @" : MessageUtils.isPM(jmsg) ? "Private message from @" : "@"; - String subtitle = MessageUtils.isReply(jmsg) ? markdown ? MessageUtils.escapeMarkdown(StringUtils.defaultString(jmsg.getReplyQuote())) - : jmsg.getReplyQuote() - : markdown ? MessageUtils.getMessageHashTags(jmsg) : MessageUtils.getTagsString(jmsg); - sb.append(title).append(markdown ? MessageUtils.getMarkdownUser(jmsg.getUser()) : jmsg.getUser().getName()).append(":\n") + String subtitle = MessageUtils.isReply(jmsg) ? jmsg.getReplyQuote() + : compatibleWithDurov ? MessageUtils.getMessageHashTags(jmsg) : MessageUtils.getTagsString(jmsg); + sb.append(title).append(compatibleWithDurov ? MessageUtils.getUserHtmlLink(jmsg.getUser(), domain) : jmsg.getUser().getName()).append(":\n") .append(subtitle).append("\n"); - if (markdown) { - sb.append(MessageUtils.formatMarkdownText(jmsg)); - } else { - sb.append(StringUtils.defaultString(jmsg.getText())); - } + sb.append(compatibleWithDurov? MessageUtils.formatMessage(jmsg.getText(), true) : StringUtils.defaultString(jmsg.getText())); sb.append("\n"); - if (!markdown && StringUtils.isNotEmpty(jmsg.getAttachmentType())) { + if (!compatibleWithDurov && StringUtils.isNotEmpty(jmsg.getAttachmentType())) { sb.append(MessageUtils.attachmentUrl(jmsg)); } return sb.toString(); |