| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM.
I dont like that we support this, but if the majority thinks this is good, I am okay with it
Sorry, something went wrong.
|
It's perfectly possible to pass parameters with GET methods, it's one of 4 supported ways to pass parameters https://core.telegram.org/bots/api#making-requests . Alternatively, there's no need for those methods to use GET instead of POST. Having a separate api_kwargs or similar is better than having **kwargs with warning.
|
Sorry, something went wrong.
|
The url = '{0}/{endpointName}'.format(self.base_url) logic can probably be moved into _post/_get methods. This would also make it easier to call not yet supported api methods. And since there's no need to have both _get and _post they could be replaced with a single Bot._api_call(endpoint, data, timeout) or something like that. |
Sorry, something went wrong.
|
It seems like there's already bot api specific code in Request.post (e.g. elif key == 'media':) so perhaps instead of spreading the logic across a whole new level of Bot._post / Bot._api_call it should be moved into Request.post. Since Request is already specialized for bot api it would make sense for it to have base_url attribute. Or maybe api_call can be made a Request method and bot api specific logic moved into it out of both Request.post and Bot._post. The recent bug with reply_markup.to_json vs reply_markup.to_dict when uploading a file could be avoided if Request.post handled the conversion of TelegramObject(or perhaps just ReplyMarkup) like it already does for InputFile. |
Sorry, something went wrong.
As I understood from the discussion with Noam about that recent bug, Requests only task should be the network stuff and mingling the "responsibilities" of Bot and Request is not advisable. The InputFile related stuff in Request is just there to handle uploading files, which is network stuff. Unifying the construction of the URL, seems a good idea to me, too. Putting it in Requests not, for above reasoning. |
Sorry, something went wrong.
|
Where does network stuff end and bot stuff begin? In context of dealing with Bot API, setting base url is about as close to network stuff as setting a proxy is. Request is not some abstract network wrapper at this point, it's made specifically for requests to Bot API, trying to generalize it might needlessly increase code complexity. |
Sorry, something went wrong.
There was a problem hiding this comment.
I;m starting to lean towards @n5y 's argument. Not specifically we need to protect users from early mistakes, but that additional kwarg adding should be explicit. That way we can reduce the warnings.
The option to add api_kwargs to every bot method which will be added to the data_dict silently. and removing **kwargs seems good to me.
Sorry, something went wrong.
|
Just noticed that the doc strings of the file types get_file should also be updated. Will do soonish. Edit: Done |
Sorry, something went wrong.
# Conflicts: # telegram/bot.py # telegram/utils/request.py
There was a problem hiding this comment.
Great change! I love this solution and I thank you for putting this much effort into it. It looks way better now, great stuff.
Sorry, something went wrong.
* Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods
* Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods
* Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods
* Refactor handling of `default_quote` * Make it a breaking change * Pickle a bots defaults * Temporarily enable tests for the v13 branch * Temporarily enable tests for the v13 branch * Refactor handling of kwargs in Bot methods (#1924) * Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods * Refactor JobQueue (#1981) * First go on refactoring JobQueue * Temporarily enable tests for the v13 branch * Work on tests * Temporarily enable tests for the v13 branch * Increase coverage * Remove JobQueue.tick() # Was intended for interal use anyways # Fixes tests * Address review * Temporarily enable tests for the v13 branch * Address review * Dispatch errors * Fix handling of job_kwargs * Remove possibility to pass a Bot to JobQueue * Refactor persistence of Bot instances (#1994) * Refactor persistence of bots * User BP.set_bot in Dispatcher * Temporarily enable tests for the v13 branch * Add documentation * Add warning to Updater for passing both defaults and bot * Address review * Fix test
* Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods
* Refactor handling of `default_quote` * Make it a breaking change * Pickle a bots defaults * Temporarily enable tests for the v13 branch * Temporarily enable tests for the v13 branch * Refactor handling of kwargs in Bot methods (#1924) * Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods * Refactor JobQueue (#1981) * First go on refactoring JobQueue * Temporarily enable tests for the v13 branch * Work on tests * Temporarily enable tests for the v13 branch * Increase coverage * Remove JobQueue.tick() # Was intended for interal use anyways # Fixes tests * Address review * Temporarily enable tests for the v13 branch * Address review * Dispatch errors * Fix handling of job_kwargs * Remove possibility to pass a Bot to JobQueue * Refactor persistence of Bot instances (#1994) * Refactor persistence of bots * User BP.set_bot in Dispatcher * Temporarily enable tests for the v13 branch * Add documentation * Add warning to Updater for passing both defaults and bot * Address review * Fix test
* Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods
* Refactor handling of `default_quote` * Make it a breaking change * Pickle a bots defaults * Temporarily enable tests for the v13 branch * Temporarily enable tests for the v13 branch * Refactor handling of kwargs in Bot methods (#1924) * Unify kwargs handling in Bot methods * Remove Request.get, make api_kwargs an explicit argument, move note to head of Bot class * Fix test_official * Update get_file methods * Refactor JobQueue (#1981) * First go on refactoring JobQueue * Temporarily enable tests for the v13 branch * Work on tests * Temporarily enable tests for the v13 branch * Increase coverage * Remove JobQueue.tick() # Was intended for interal use anyways # Fixes tests * Address review * Temporarily enable tests for the v13 branch * Address review * Dispatch errors * Fix handling of job_kwargs * Remove possibility to pass a Bot to JobQueue * Refactor persistence of Bot instances (#1994) * Refactor persistence of bots * User BP.set_bot in Dispatcher * Temporarily enable tests for the v13 branch * Add documentation * Add warning to Updater for passing both defaults and bot * Address review * Fix test
| Back | FazBrowse Home | New Git URL |
Closes #1918
Note: I removed a part of Bot.set_webhook that was intended for backwards compatibility, as it used **kwargs. However, git blame tells me that it's 4 years old and from API 2.3.1 (?). So I thinks it's fair to say that it's not needed anymore.