Closed rsimonru closed 3 years ago
Hello!
I'm a bit confused what config data you telling about. If you mean bot-config, there is no way to access bot's config from bot instance when it's already created currently. And i'm not sure that this is needed, as you writing config by yourself - if you need some data from config you may store your config as array and use it later as you need it. Or if you are using laravel you may use config('telebot.bots')
function to get your all bots configs anywhere from your app.
You can't change config "on the go" by the way. You may change laravel variables using Config::set('key.to.config.var')
but bot instances will not be recreated as app creates them as singletons.
From UpdateHandler
and CommandHandler
you may get current TeleBot
instance using $this->bot
Hello.
Thank for quick response. I'm trying to explain better. I'm using Laravel and my question is how to know the bot's local config name or token, for example, in an UpdateHandler. When an update is received, I have $this->update and $this->bot and I can use all Telegram methods, but how I know the related local config for the bot related to Update? With config('telebot.bots')
I can access all the bots config, but what is the update's bot config?
Oh, I see now. I now can imagine condition where you may want to reuse UpdateHandler
for different bots and get access to current bot name/token. Yeah, currently you can't do that comfortably as functionality for bot validation is related to BotManager
. I think you proposed the best way to do that - just add ability to get bots config from the bot instance using method. This need to be done for sure.
Wonderful and very quick solution
It's there a way to access to local config data in an update handler? When an update is received, how I know the related bot?. I can get Telegram bot info, but I don't know how to get local config info. Perhaps new methods in TeleBot class?