Bot api 3.2 - #732
Conversation
* get_sticker_set * upload_sticker_file * create_new_sticker_set * add_sticker_to_set * set_sticker_position_in_set * delete_sticker_from_set
Change it so it works, but add a todo notice about it Also add missing **kwargs so it's for robust in future
NOTE: Currently not testing StickerSet in terms of bot methods (interaction with telegrams servers)
thodnev
left a comment
There was a problem hiding this comment.
Not a full review, just a quick look
Looks good to me, but I've not tested it.
| if not data: | ||
| return list() | ||
|
|
||
| stickers = list() |
There was a problem hiding this comment.
It's better to use comprehensions etc here like:
stickers = [Sticker.de_json(ix, bot) for ix in data]
There was a problem hiding this comment.
Hmm, you're probably right, I just wrote it like we had in other places. I'll change it though.
|
|
||
| @staticmethod | ||
| def de_json(data, bot): | ||
| if not data: |
There was a problem hiding this comment.
Probably we need to raise an exception here or make it return empty stickerset. Exception looks better in my opinion
There was a problem hiding this comment.
Nah, it's never been needed before in any of the other de_json, so we should be 100% fine
| MOUTH = 'mouth' | ||
| CHIN = 'chin' | ||
|
|
||
| def __init__(self, point, x_shift, y_shift, zoom, **kwargs): |
There was a problem hiding this comment.
If it's used mainly for storage it's better to use slots
There was a problem hiding this comment.
Hmm. We don't use slots anywhere else, should we?
There was a problem hiding this comment.
constants all over the lib. Suggesting same approach here.
Eldinnie
left a comment
There was a problem hiding this comment.
Mostly docstring stuff.
One important thing I ask is to remove **kwargs from the bot methods and their docstrings.
| **kwargs (:obj:`dict`): Arbitrary keyword arguments. | ||
|
|
||
| Returns: | ||
| :class:`telegramStickerSet` |
There was a problem hiding this comment.
Missing a . here (telegram.StickerSet)
| def upload_sticker_file(self, user_id, png_sticker, timeout=None, **kwargs): | ||
| """ | ||
| Use this method to upload a .png file with a sticker for later use in | ||
| :attr:`create_new_sticker_set` and :attr:`add_sticker_to_set methods` (can be used multiple |
There was a problem hiding this comment.
closing ``` is after methods, should close at _set
| ``open(filename, 'rb')`` | ||
|
|
||
| Args: | ||
| user_id (int): User identifier of sticker file owner. |
|
|
||
| url = '{0}/getStickerSet'.format(self.base_url) | ||
|
|
||
| data = {'name': name} |
There was a problem hiding this comment.
Definging **kwargs in arguments but not adding them to data is useless. I suggest removing them from arguments.
There was a problem hiding this comment.
Good catch @Eldinnie
kwargs are automatically passed when using the @message decorator, but if it's not being used, than they should be pushed in the data dictionary.
the reason for that, is to allow forward compatibility (lets say telegram adds some arguments t an existing API call, then users can use the new API even before we release an official support).
There was a problem hiding this comment.
anyway, we can fix that in another PR as it's not the only place where we missed that.
|
|
||
| url = '{0}/uploadStickerFile'.format(self.base_url) | ||
|
|
||
| data = {'user_id': user_id, 'png_sticker': png_sticker} |
| **kwargs (:obj:`dict`): Arbitrary keyword arguments. | ||
|
|
||
| Returns: | ||
| :obj:`bool` On success, ``True`` is returned. |
| Use this method to delete a sticker from a set created by the bot. | ||
|
|
||
| Args: | ||
| sticker (:obj:`str`): File identifier of the sticker |
| timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as | ||
| the read timeout from the server (instead of the one specified during | ||
| creation of the connection pool). | ||
| **kwargs (:obj:`dict`): Arbitrary keyword arguments. |
| **kwargs (:obj:`dict`): Arbitrary keyword arguments. | ||
|
|
||
| Returns: | ||
| :obj:`bool` On success, ``True`` is returned. |
| MOUTH = 'mouth' | ||
| CHIN = 'chin' | ||
|
|
||
| def __init__(self, point, x_shift, y_shift, zoom, **kwargs): |
There was a problem hiding this comment.
constants all over the lib. Suggesting same approach here.
Added new style docstrings for: Sticker StickerSet MaskPosition
|
The failed build is due to a possible bug in telegrams documentation. I've already contacted botsupport. Should I add an overwrite so our builds pass or do we wanna wait for a reply? |
Closes #730
Note the lack of proper tests for StickerSet... it's hard test creation and such when we can't delete them afterwards.
Every bot method is documented as per new standard in #728. I have not added or changed the object docs for Sticker, StickerSet and MaskPosition however since that would potentially conflict with #728, so it's easier to just leave that to @Eldinnie :)