使用电报机器人 (telegraf)、nodejs 发送降价文本

Send markdown text with telegram bot (telegraf), nodejs

如何使用 nodejs 上的 telegraf 库通过电报机器人发送降价文本?

const token = 'YOUR TOKEN';
const Telegraf = require('telegraf')
const extra = require('telegraf/extra')
const markup = extra.markdown()

const telegram = new Telegraf(token)

telegram.telegram.sendMessage('there chat id', 'your message', markup)

如果您在导入模块中使用上下文对象ctx来回复并且不想导入Telegraf,那么您可以使用:

ctx.reply('some _text_', {reply_markup: 'markdown'})
ctx.replyWithMarkdown(MESSAGE)

使用 telegraf v4.3.0,我使用以下代码让它工作:

const bot = new Telegraf(token);
bot.telegram.sendMessage('my chat id', 'my text', { parse_mode: 'MarkdownV2' });