使用javanetbeans在telegram机器人上发送粗体文本
我的telegram机器人正在工作,但我想对我发送的消息进行一些修改,例如发送粗体、斜体或删除线文本,我尝试使用Unicode中的“code”(因为这样我就可以为警笛表情符号发送“\uD83D\uDEA8”等表情符号)来发送粗体,但不起作用,这是我的代码:
String startBold = "\\033[1m";
String endBold = "\\033[0;0m";
String msg = "The" + startBold + " text" + endBold + " is bold.";
String json = "{\"chatId\":\"<<chatId>>\",\"key\":\"<<key>>\",\"botId\":\"<<botId>>\",\"msg\":\" " + msg + " \",\"username\":\"<<username>>\"}";
String url = "https://sendMessage.com/rest-messaging/service/bot/sendMessage";
StringEntity body = new StringEntity(json.toString());
String result = sendMessage.telegramNotifications(url, json);
# 1 楼答案
Telegram允许您使用标记来设置文本格式
你可以用
*
将文本加粗,例如:*bold text*
请注意,您必须将
parse_mode
切换到Markdown
或MarkdownV2
才能工作更多信息:core.telegram.org/bots/api#formatting-options