Ad
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)
.
Ad
Answer
This reason yours isn't working is because you called it parse_mode
instead of parseMode
(See doc)
Try this, it should work.
const TeleBot = require('telebot');
const bot = new TeleBot('35353453:sfsdfsdffgrtyrty454646thfhfgfgh')
bot.on(/^\/s (.+)$/, async function(msg, props) {
const id = msg.chat.id;
const url = "https://google.com";
const message = `Read more about [Google](${url}) now!!!!`;
return bot.sendMessage(id, message, { parseMode: 'Markdown' });
});
bot.start();
Okay, I tested it and it works well. I sent /s ert
and here was the response:
So now let me click Google
and you'll see the popup:
THERE YOU GO. Hope it helps
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad