Reputation: 41
How can i use Markdown OR html at sendMessage?
https://core.telegram.org/bots/api#sendmessage
My code of example is :
public void onUpdateReceived(Update update) {
// We check if the update has a message and the message has text
SendMessage sendMessage = new SendMessage().setChatId(update.getMessage().getChatId());
sendMessage.setText("Mensaje Recibido ...." + update.getMessage().getText());
sendMessage.setText("<a href="+"http://www.example.com/"+">inline URL</a>");
try {
sendMessage(sendMessage);
} catch (TelegramApiException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
the result is :
Upvotes: 1
Views: 4877
Reputation: 91
you should to do it this way:
SendMessage message = new SendMessage()
.enableMarkdown(true)
.setChatId(chat_id)
.setText("[url name](http://www.url_name.com/)");
try {
execute(message);
} catch (TelegramApiException e) {
e.printStackTrace();
}
this is not working with localhost, then you should to replace localhost to 127.0.0.1
Upvotes: 0
Reputation: 101
Enable markdown, set to true
SendMessage message = new SendMessage()
.enableMarkdown(true)
.setChatId(chat_id)
.setText(yourMessage);
try {
execute(message);
} catch (TelegramApiException e) {
e.printStackTrace();
}
Upvotes: 1