You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I couldn't find any description anywhere on how to make the bot send requests to the Telegram test environment (if there is any mention of it somewhere, please let me know).
I suggest adding an option to the bot called "mode," which will have values Prod (by default) / Test.
As an example, this can be done as follows:
let bot = Bot::from_env().set_mode(teloxide_core::bot::Mode::Test);
Then pass the value of mode to the function for creating the URL request:
// teloxide_core::netfnmethod_url(base: reqwest::Url,token:&str,method_name:&str,mode: bot::Mode) -> reqwest::Url{match mode {
bot::Mode::Prod => base.join(&format!("/bot{token}/{method_name}")).expect("failed to format url"),
bot::Mode::Test => base.join(&format!("/bot{token}/test/{method_name}")).expect("failed to format url")}}
Pros
Ability to execute commands in the test environment
Cons
Unable to find
The text was updated successfully, but these errors were encountered:
There is Bot::set_api_url, which allows you to change thr bot API server url. As a workaround you could setup a reverse proxy which would redirect https://proxy/bot{token}/{method_name} to https://api.telegram.org/bot{token}/test/{method_name}.
I'm not sure I like the "mode enum" solution. Should we maybe just allow you to forge the full url? i.e. store something like fn(&str, &str) -> Url in the bot?
There is Bot::set_api_url, which allows you to change thr bot API server url.
If I understand correctly, api_url will replace base in the method for creating the URL and add /bot{token}/{method_name}, which should not allow me to insert /test after the bot token.
It seems too convoluted for such a task. I'll have to set up a separate proxy application that is only needed for testing purposes. I'll try to implement this approach for now.
Should we maybe just allow you to forge the full url? i.e. store something like fn(&str, &str) -> Url in the bot?
Regarding this, I think it wouldn't hurt to consider the possibility of working with the test environment in a more convenient way than using a separate proxy 🤓
To be clear: the proxy thing is a workaround, not a solution. I think it's reasonable to expect teloxide to provide a convenient way of calling into the test environment.
I couldn't find any description anywhere on how to make the bot send requests to the Telegram test environment (if there is any mention of it somewhere, please let me know).
I suggest adding an option to the bot called "mode," which will have values Prod (by default) / Test.
As an example, this can be done as follows:
Then pass the value of mode to the function for creating the URL request:
Pros
Cons
Unable to find
The text was updated successfully, but these errors were encountered: