So, i need to find in what case there should be an error answer: 400: ENTITIES_TOO_LONG You provided too many styled message entites
I have tg channel and bot added in this channel.
I read telegram API documantation and there is no good explanation of this error.
First of all, i tried to test some cases, for example:
public String generateEntitiesString(int amount) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < amount; i++) {
sb.append(String.format("[<view merge request\>](%s)", "https://github.com/")+ "n");
}
return sb.toString();
}
I wrote simple code that generates content of the message sended by channel bot. And i found that the max amount of styled text entities is 100. After that all formatted text, such as ~text~ will be ignored. That’s why i don’t understand i will catch 400: ENTITIES_TOO_LONG.
To more information, i send message via class extends DefaultAbsSender like this:
public void sendMessage(String chatId, String content) {
try {
sendApiMethod(SendMessage.builder()
.parseMode("MarkdownV2")
.chatId(chatId)
.text(content)
.build());
log.info("Message sended, chatId={}", chatId);
} catch (TelegramApiException e) {
log.error("Error, chatId={}, content={}", chatId, content, e);
}
}