aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/TelegramBotManager.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-01-12 11:46:40 +0300
committerGravatar Vitaly Takmazov2023-01-12 11:56:11 +0300
commite377357b00cdb151aa20d96a0ce7a5f1a8bbe9c9 (patch)
tree8e776a6705e71eb72e8ea48bb3d345bc0e96fa6c /src/main/java/com/juick/TelegramBotManager.java
parent84f6e27f7e563bcb58815575546c52c944f0cd3e (diff)
Telegram: parse_mode=html
Diffstat (limited to 'src/main/java/com/juick/TelegramBotManager.java')
-rw-r--r--src/main/java/com/juick/TelegramBotManager.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/main/java/com/juick/TelegramBotManager.java b/src/main/java/com/juick/TelegramBotManager.java
index 9d0b5862..6a150bef 100644
--- a/src/main/java/com/juick/TelegramBotManager.java
+++ b/src/main/java/com/juick/TelegramBotManager.java
@@ -285,7 +285,7 @@ public class TelegramBotManager implements NotificationListener {
messagesService.setMessageProperty(newMessage.getMid(), newMessage.getRid(), "durovId",
String.valueOf(messageId));
}
- String messageTxt = StringUtils.isNotEmpty(result.getMarkdown()) ? result.getMarkdown()
+ String messageTxt = StringUtils.isNotEmpty(result.getText()) ? result.getHtml()
: "Unknown error or unsupported command";
telegramNotify(userId, messageTxt, new com.juick.model.Message());
} catch (Exception e) {
@@ -309,7 +309,7 @@ public class TelegramBotManager implements NotificationListener {
if (replyTo > 0) {
telegramPhoto.replyToMessageId(replyTo);
}
- telegramPhoto.parseMode(ParseMode.Markdown);
+ telegramPhoto.parseMode(ParseMode.HTML);
if(msg.length() < 1024) {
telegramPhoto.caption(msg);
isSendTxt = false;
@@ -335,7 +335,7 @@ public class TelegramBotManager implements NotificationListener {
if (replyTo > 0) {
telegramMessage.replyToMessageId(replyTo);
}
- telegramMessage.parseMode(ParseMode.Markdown).disableWebPagePreview(true);
+ telegramMessage.parseMode(ParseMode.HTML).disableWebPagePreview(true);
bot.execute(telegramMessage, new Callback<>() {
@Override
public void onResponse(SendMessage request, SendResponse response) {
@@ -425,7 +425,7 @@ public class TelegramBotManager implements NotificationListener {
}
}
private String formatTelegramMessage(com.juick.model.Message jmsg) {
- return String.format("[%s](%s) %s", MSG_LINK, formatUrl(jmsg), formatPost(jmsg, true));
+ return String.format("<a href='%s'>%s</a> %s", formatUrl(jmsg), MSG_LINK, formatPost(jmsg, true, webDomain));
}
private void processMessage(com.juick.model.Message jmsg, List<User> subscribedUsers) {
if (jmsg.isService()) {
@@ -434,7 +434,7 @@ public class TelegramBotManager implements NotificationListener {
String msgUrl = formatUrl(jmsg);
if (MessageUtils.isPM(jmsg)) {
telegramService.getTelegramIdentifiers(Collections.singletonList(jmsg.getTo()))
- .forEach(c -> telegramNotify(c, formatPost(jmsg, true), jmsg));
+ .forEach(c -> telegramNotify(c, formatPost(jmsg, true, webDomain), jmsg));
} else if (MessageUtils.isReply(jmsg)) {
String fmsg = formatTelegramMessage(jmsg);
telegramService.getTelegramIdentifiers(
@@ -458,11 +458,11 @@ public class TelegramBotManager implements NotificationListener {
if (!userService.isInBLAny(message.getUser().getUid(), liker.getUid())) {
telegramService.getTelegramIdentifiers(Collections.singletonList(message.getUser()))
.forEach(c -> telegramNotify(c, String.format("%s recommends your [post](%s)",
- MessageUtils.getMarkdownUser(liker), formatUrl(message)), new com.juick.model.Message()));
+ MessageUtils.getUserHtmlLink(liker, webDomain), formatUrl(message)), new com.juick.model.Message()));
}
telegramService.getTelegramIdentifiers(subscribers)
.forEach(c -> telegramNotify(c, String.format("%s recommends you someone's [post](%s)",
- MessageUtils.getMarkdownUser(liker), formatUrl(message)), new com.juick.model.Message()));
+ MessageUtils.getUserHtmlLink(liker, webDomain), formatUrl(message)), new com.juick.model.Message()));
}
@Override
@@ -480,6 +480,6 @@ public class TelegramBotManager implements NotificationListener {
private void processFollow(User subscriber, List<User> target) {
telegramService.getTelegramIdentifiers(target)
.forEach(c -> telegramNotify(c, String.format("%s subscribed to your blog",
- MessageUtils.getMarkdownUser(subscriber)), new com.juick.model.Message()));
+ MessageUtils.getUserHtmlLink(subscriber, webDomain)), new com.juick.model.Message()));
}
}