@flexpc

Почему не получается создать стикер пак aiogram?

читал оф. документацию для третей версии по теме создания стикер пака. Повторил все так, как там.
class InputSticker:
            def __init__(self, sticker):
                self.sticker = sticker

 ready_stickers = []
        for i in range(len(jsonRequest["stickers"])):
            background = Path("assets", "blanks", jsonStickers[i]["background"] + ".png")
            emoji = Path("assets", "blanks", jsonStickers[i]["emoji"] + ".png")
            text = Path("assets", "blanks", jsonStickers[i]["text"] + ".png")
            
            background_img = Image.open(background)
            emoji_img = Image.open(emoji)
            text_img = Image.open(text)
            
            background_img.paste(emoji_img, (0, 0), emoji_img)
            background_img.paste(text_img, (0, 0), text_img)
            
            sticker_obj = InputSticker(background_img)
            
            ready_stickers.append(sticker_obj)

bot = aiogram.Bot(token=os.getenv("TOKEN")) 
stickerset_name = ''.join(secrets.choice(string.ascii_letters + string.digits) for x in range(64)) 
isSuccess = bot.create_new_sticker_set(user_id=int(os.getenv("USER_ID")), name=stickerset_name, title=os.getenv("TITLE"), stickers=ready_stickers, sticker_format="static")


Но вижу ошибку
Bot.create_new_sticker_set() got an unexpected keyword argument 'stickers'

(Если что я использую джанго на сервере)

Если перейти по методу, то он будет такой
async def create_new_sticker_set(
        self,
        user_id: int,
        name: str,
        title: str,
        emojis: str,
        png_sticker: Optional[Union[InputFile, str]] = None,
        tgs_sticker: Optional[InputFile] = None,
        webm_sticker: Optional[InputFile] = None,
        sticker_type: Optional[str] = None,
        mask_position: Optional[MaskPosition] = None,
        request_timeout: Optional[int] = None,
    ) -> bool:
        """
        Use this method to create a new sticker set owned by a user. The bot will be able to edit the sticker set thus created. You **must** use exactly one of the fields *png_sticker*, *tgs_sticker*, or *webm_sticker*. Returns :code:`True` on success.

        Source: https://core.telegram.org/bots/api#createnewstickerset

        :param user_id: User identifier of created sticker set owner
        :param name: Short name of sticker set, to be used in :code:`t.me/addstickers/` URLs (e.g., *animals*). Can contain only English letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in :code:`"_by_<bot_username>"`. :code:`<bot_username>` is case insensitive. 1-64 characters.
        :param title: Sticker set title, 1-64 characters
        :param emojis: One or more emoji corresponding to the sticker
        :param png_sticker: **PNG** image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a *file_id* as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. :ref:`More information on Sending Files » <sending-files>`
        :param tgs_sticker: **TGS** animation with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_`https://core.telegram.org/stickers#animated-sticker-requirements <https://core.telegram.org/stickers#animated-sticker-requirements>`_ for technical requirements
        :param webm_sticker: **WEBM** video with the sticker, uploaded using multipart/form-data. See `https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_`https://core.telegram.org/stickers#video-sticker-requirements <https://core.telegram.org/stickers#video-sticker-requirements>`_ for technical requirements
        :param sticker_type: Type of stickers in the set, pass 'regular' or 'mask'. Custom emoji sticker sets can't be created via the Bot API at the moment. By default, a regular sticker set is created.
        :param mask_position: A JSON-serialized object for position where the mask should be placed on faces
        :param request_timeout: Request timeout
        :return: Returns :code:`True` on success.
        """

        call = CreateNewStickerSet(
            user_id=user_id,
            name=name,
            title=title,
            emojis=emojis,
            png_sticker=png_sticker,
            tgs_sticker=tgs_sticker,
            webm_sticker=webm_sticker,
            sticker_type=sticker_type,
            mask_position=mask_position,
        )
        return await self(call, request_timeout=request_timeout)

Наверно вы заметили, что stickers и sticker_format, там вообще не описаны, хотя сделано все как в документации.
Что с этим делать, мне вообще не понятно, мучаюсь уже третий час.
pip freeze =>
aiofiles==23.1.0
aiogram==3.0.0b7
aiohttp==3.8.4
aiosignal==1.3.1
asgiref==3.7.2
async-timeout==4.0.2
attrs==23.1.0
Babel==2.9.1
certifi==2023.5.7
charset-normalizer==3.1.0
Django==4.2.2
djangorestframework==3.14.0
frozenlist==1.3.3
idna==3.4
magic-filter==1.0.9
multidict==6.0.4
Pillow==9.5.0
pydantic==1.10.9
python-dotenv==1.0.0
pytz==2023.3
sqlparse==0.4.4
typing_extensions==4.6.3
tzdata==2023.3
yarl==1.9.2

Python - 3.10.9
  • Вопрос задан
  • 297 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы