Add a reference to the telegraf bot instance to the telegrafContext
See original GitHub issueIs your feature request related to a problem? Please describe. Trying to write a middleware that wants to access the bots api currently requires you to pass the instance of the bot to the middlewares constructor. It would be easier if the bot would be available in every context that is passed to the middleware handler.
Describe the solution you’d like Add a reference to the telegraf bot instance to TelegrafContext
bot.use((ctx, next)=>{
console.log(ctx.bot);
next();
});
Describe alternatives you’ve considered The alternative would be something like (in case the middleware is not living inside the scope of the bots creation)
bot.use(((bot)=>(ctx, next)=>{
console.log(bot);
next();
})(bot));
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:13 (4 by maintainers)
Top Results From Across the Web
telegraf.js - v4.11.2
Documentation for telegraf.js - v4.11.2. ... Bots are special Telegram accounts designed to handle messages automatically. ... yarn add telegraf.
Read more >Telegraf: Modern Telegram Bot Framework for Node.js
Context. A Telegraf Context encapsulates telegram update. Context is created per request and contains following props: Property, Description ...
Read more >Telegraf Context - YouTube
Build Telegram Chat Bots with Node.js using the Modern Telegraf Framework ...
Read more >How To Build a Telegram Quotes Generator Bot With Node.js ...
In this tutorial, you will use Node.js, Telegraf, Jimp, and the Pexels API to ... add the following code to create an instance...
Read more >Build a Telegram Bot using TypeScript, Node.js, and Telegraf ...
Add TypeScript. TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. Add ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes something like that. Not entirely useful with this example because the middleware already gets everything ever send to the bot, but in my case I want to modify the inner workings of the bot upon request… It’s not like that it is impossible right now, I just think that this addition would make some code a little nicer.