Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] StickerSet require parameters that API no longer sends #4181

Closed
kaine119 opened this issue Apr 1, 2024 · 6 comments · Fixed by #4180
Closed

[BUG] StickerSet require parameters that API no longer sends #4181

kaine119 opened this issue Apr 1, 2024 · 6 comments · Fixed by #4180

Comments

@kaine119
Copy link

kaine119 commented Apr 1, 2024

Steps to Reproduce

  1. Call bot.get_sticker_set(name)

Expected behaviour

.get_sticker_set() should return a StickerSet object

Actual behaviour

.get_sticker_set() throws: TypeError: StickerSet.__init__() missing 2 required positional arguments: 'is_animated' and 'is_video'

Operating System

Windows

Version of Python, python-telegram-bot & dependencies

python-telegram-bot 20.8
Bot API 7.0
Python 3.11.7 (tags/v3.11.7:fa7a6f2, Dec  4 2023, 19:24:49) [MSC v.1937 64 bit (AMD64)]

Relevant log output

File "C:\Users\...\env\Lib\site-packages\telegram\ext\_extbot.py", line 1934, in get_sticker_set
    return await super().get_sticker_set(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\...\env\Lib\site-packages\telegram\_bot.py", line 542, in decorator
    result = await func(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\...\env\Lib\site-packages\telegram\_bot.py", line 6092, in get_sticker_set
    return StickerSet.de_json(result, self)  # type: ignore[return-value]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\...\env\Lib\site-packages\telegram\_files\sticker.py", line 330, in de_json
    return super()._de_json(data=data, bot=bot, api_kwargs=api_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\...\env\Lib\site-packages\telegram\_telegramobject.py", line 403, in _de_json
    raise exc
  File "C:\Users\...\env\Lib\site-packages\telegram\_telegramobject.py", line 400, in _de_json
    obj = cls(**data, api_kwargs=api_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: StickerSet.__init__() missing 2 required positional arguments: 'is_animated' and 'is_video'

Additional Context

Telegram seems to be gearing up to allow mixed-media sticker packs. From yesterday's update:

Mixed-Format Sticker Packs

  • Removed the fields is_animated and is_video from the class StickerSet.
  • Added the field format to the class InputSticker.

Not sure if they've made any other announcements yet, but the StickerSet class may need to be reworked.

@kaine119
Copy link
Author

kaine119 commented Apr 1, 2024

From @botnews:

Stickers

@harshil21
Copy link
Member

Hi, thanks for the issue. This is known by the dev team, and we are working on the next update which will fix this. For now a workaround is to use Bot.do_api_request("get_sticker_set", {"name": sticker_set_name}). There will be a channel post on this soon.

@Worrah
Copy link

Worrah commented Apr 4, 2024

Hi, thanks for the issue. This is known by the dev team, and we are working on the next update which will fix this. For now a workaround is to use Bot.do_api_request("get_sticker_set", {"name": sticker_set_name}). There will be a channel post on this soon.

im sorry, but what if i am using the python-telegram-bot 12.5 ? no chance to use it?

@harshil21
Copy link
Member

Hi, thanks for the issue. This is known by the dev team, and we are working on the next update which will fix this. For now a workaround is to use Bot.do_api_request("get_sticker_set", {"name": sticker_set_name}). There will be a channel post on this soon.

im sorry, but what if i am using the python-telegram-bot 12.5 ? no chance to use it?

No, that version is more than 5 years old.

Bibo-Joshi added a commit that referenced this issue Apr 12, 2024
Co-authored-by: Mahdyar Hasanpour <mahdyar@duck.com>
Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com>
Co-authored-by: Abdelrahman Elkheir <90580077+aelkheir@users.noreply.github.com>
Co-authored-by: Aditya <adityayadav11082@gmail.com>
@starry-shivam
Copy link
Member

starry-shivam commented Apr 14, 2024

im sorry, but what if i am using the python-telegram-bot 12.5 ? no chance to use it?

You can do something like this:

resp = bot._request.post(
        f"{bot.base_url}/getStickerSet",
        {
            "name": packname,
        },
    )

Then, manually call StickerSet.de_json() on the returned data, or just use the json data directly. It's a bit of a dirty hack, requiring access to a private property, I know, but it's better than nothing if you're for whatever reason stuck with v12/13.x

@Worrah
Copy link

Worrah commented Apr 14, 2024

im sorry, but what if i am using the python-telegram-bot 12.5 ? no chance to use it?

You can do something like this:

resp = bot._request.post(
        f"{bot.base_url}/getStickerSet",
        {
            "name": packname,
        },
    )

Then, manually call StickerSet.de_json() on the returned data, or just use the json data directly. It's a bit of a dirty hack, requiring access to a private property, I know, but it's better than nothing if you're for whatever reason stuck with v12/13.x

well, i already saved every sticker id one by one =_= but thank you anyway :D

@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants