mirror of
https://github.com/valitydev/alert-tg-bot.git
synced 2024-11-06 01:55:23 +00:00
Escape special characters inside alert name (#13)
This commit is contained in:
parent
e068525360
commit
430d5c3b4f
@ -60,7 +60,8 @@ public class MenuCallbackMapper {
|
||||
if (!userAlerts.isEmpty()) {
|
||||
StringBuilder text = new StringBuilder("Ваши алерты:\n");
|
||||
userAlerts.forEach(userAlert -> text.append("*id:* ").append(userAlert.getId())
|
||||
.append("\n*Название:* ").append(userAlert.getName())
|
||||
.append("\n*Название:* ")
|
||||
.append(escapeSpecialCharacters(userAlert.getName()))
|
||||
.append("\n"));
|
||||
message.setText(text.toString());
|
||||
message.setParseMode("MarkdownV2");
|
||||
@ -93,4 +94,13 @@ public class MenuCallbackMapper {
|
||||
message.setReplyMarkup(buildMainInlineKeyboardMarkup());
|
||||
return message;
|
||||
}
|
||||
|
||||
private String escapeSpecialCharacters(String message) {
|
||||
return message
|
||||
.replace("_", "\\_")
|
||||
.replace("*", "\\*")
|
||||
.replace("[", "\\[")
|
||||
.replace("`", "\\`")
|
||||
.replace(".", "\\.");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user