node.js - How to use 'Markdown' in parse_mode of telegram bot?
问题描述
bot.on(/^\/s (.+)$/, async function(msg, props) {
let id = msg.chat.id;
let message = await MyBot.getBySearchQuery(props.match[1]);
let parse_mode = 'Markdown';
return bot.sendMessage(id, message, { parse_mode });
});
By /s <param>
I want to get some hyperlink in telegram. But instead of that I'm getting [hyperlink](http://some_url)
.
What is going wrong here? The message
here is always a string like [title](url)
.
解决方案
Are you using the node-telegram-bot-api npm module?
I think you want to be using bot.onText
method not .on
. I've just tried with both, and when using .on the callback function never runs.
bot.onText(/^\/s (.+)$/, async function(msg, props) {
let id = msg.chat.id;
let message = await MyBot.getBySearchQuery(props.match[1]);
let parse_mode = 'Markdown';
return bot.sendMessage(id, message, { parse_mode });
});
Have you tried adding some kind of logging to this method to see if it ever actually runs, and that your getBySearchQuery(..)
is returning the expected message?
推荐阅读
- javascript - 循环遍历 JSON 数据并动态显示它们
- logic - 什么是“可计算函数的逻辑”?
- u-boot - U-boot 源码中的 eth_device 结构处理
- arrays - MongoDB:如何将对象添加到数组中?
- hive - 在使用 Avro 构建的配置单元表中使用 order by 时出错
- apache-kafka - Spark Structured Streaming 和 Kafka 的意外速率限制
- android - Paging 3 PagingSource 类根本不加载
- bash - 是否有一个 bash 表达式可以用来检查当前提交是否被标记?
- opencv - 使用 OpenCV 拼接长物品的自上而下的照片
- java - 将现有 Flutter Java Android 项目转换为 Kotlin