diff options
author | Vitaly Takmazov | 2018-01-17 14:38:32 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2018-01-17 14:38:32 +0300 |
commit | be8d139d8ea58396107cf1a2b12ad16ac8bda6d6 (patch) | |
tree | b73c449f4a87b16541bc46bd697b1cf632de2c25 /juick-core/src/main/java/com/juick/util | |
parent | dadfbdb7379ebe9623643902a6a0aa78ca528228 (diff) |
api: markdown tags for telegram
Diffstat (limited to 'juick-core/src/main/java/com/juick/util')
-rw-r--r-- | juick-core/src/main/java/com/juick/util/MessageUtils.java | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/juick-core/src/main/java/com/juick/util/MessageUtils.java b/juick-core/src/main/java/com/juick/util/MessageUtils.java index aba718a5..6e0b47c0 100644 --- a/juick-core/src/main/java/com/juick/util/MessageUtils.java +++ b/juick-core/src/main/java/com/juick/util/MessageUtils.java @@ -26,6 +26,7 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * Created by aalexeev on 11/13/16. @@ -178,6 +179,10 @@ public class MessageUtils { } return hashtags.toString(); } + public static String getMarkdownTags(final Message jmsg) { + return jmsg.getTags().stream().map(t -> String.format("[%s](http://juick.com/tag/%s)", t.getName(), percentEncode(t.getName()))) + .collect(Collectors.joining(", ")); + } // TODO: check if it is really needed public static String percentEncode(final String s) { |