rubenlagus / TelegramBots

Java library to create bots using Telegram Bots API
https://telegram.me/JavaBotsApi
MIT License
4.68k stars 1.18k forks source link

problem with sending message #424

Closed Vava666 closed 6 years ago

Vava666 commented 6 years ago

Hello! I'm new with telegram bot API. I'm trying to collect information about the members of the group and display it on the command / list.

To store the list of participants I use ArrayList and when print them in cycle.

Part of code: if(message.getText().equals("/list")){ for(int i=0;i<list.size();i++){ String s = list.get(i).getName(); sendMsg(message, s); }

sending method:

private void sendMsg(Message message, String s) { SendMessage sendMessage=new SendMessage(); sendMessage.enableMarkdown(true); sendMessage.setChatId(message.getChatId().toString()); sendMessage.setReplyToMessageId(message.getMessageId()); sendMessage.setText(s); try{ execute(sendMessage); }catch (TelegramApiException e){ e.printStackTrace(); } }

finaly catch an exception:

org.telegram.telegrambots.exceptions.TelegramApiRequestException: Error sending message: [400] Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 5 at org.telegram.telegrambots.api.methods.send.SendMessage.deserializeResponse(SendMessage.java:170) at org.telegram.telegrambots.api.methods.send.SendMessage.deserializeResponse(SendMessage.java:24) at org.telegram.telegrambots.bots.DefaultAbsSender.sendApiMethod(DefaultAbsSender.java:690) at org.telegram.telegrambots.bots.AbsSender.execute(AbsSender.java:53) at TBot.sendMsg(TBot.java:79) at TBot.onUpdateReceived(TBot.java:47) at java.util.ArrayList.forEach(ArrayList.java:1257) at org.telegram.telegrambots.generics.LongPollingBot.onUpdatesReceived(LongPollingBot.java:27) at org.telegram.telegrambots.updatesreceivers.DefaultBotSession$HandlerThread.run(DefaultBotSession.java:311)

Vava666 commented 6 years ago

was a problem with Markdown. turn it of.