Задать вопрос
@pavelermolenko

Как отправить стикеры через бота?

Решил по приколу написать бота, который отправляет несколько стикеров по команде. Стикеры в ручную записал в массив. Сам код:
from aiogram import Bot, Dispatcher, executor, types
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton

stickerpack = [
    r'CAACAgIAAxkBAAEIfWBkL-mba2XI9A8YDCnq9RfpaLvP7AACLhAAAlrQgUgIvOZTf2b2xi8E'
    r'CAACAgIAAxkBAAEIfWJkL-m0mAHAGXOjq8RyTXL_KJVBpQACqhAAAol8gEh_KDETWzwMoS8E'
    r'CAACAgIAAxkBAAEIfWRkL-m3FgzL3nfml_hIVJmv9jte_gACZhMAAkSZgEic77gNT5yfcy8E'
    r'CAACAgIAAxkBAAEIfWZkL-m5_sTAGkxw0jbZea-X6-VewQACwhMAAhFPgUitYgUXV6XhNS8E'
    r'CAACAgIAAxkBAAEIfWhkL-m7K56RLCP50seBOrMs_YNNmAAC-Q8AAkizgUg1oPltMoqHDC8E'
    r'CAACAgIAAxkBAAEIfWpkL-m9CxBagEu7pvs0VhCoK8xMLgACvREAAj6deUhXRIpi8ND4lS8E'
    r'CAACAgIAAxkBAAEIfWxkL-m_6JQqNlX5swO2e7lpe34JWgACthUAAlnPgUgr9A1ygKcCRy8E'
    r'CAACAgIAAxkBAAEIfW5kL-nCq8wxCX8pJTZRh_aP7-I7XgAC0xAAAnxFgUiGdee3rCqq8S8E'
    r'CAACAgIAAxkBAAEIfXBkL-nENNa4wvbhMd8hIxftdjVC9AACyRAAAj9igUhZh24PjIvL3S8E'
    r'CAACAgIAAxkBAAEIfXJkL-nGPYw2Sanz5ExyNQvC0wd3RQACVxEAAgg9gEhH7Fkjt--PiS8E'
    r'CAACAgIAAxkBAAEIfXRkL-nIPXjFxyKBWWw41FOpVKalXQACWBEAAq3FeUgci-WzxbxyKS8E'
    r'CAACAgIAAxkBAAEIfXZkL-nJX12GlUqfziSou3N56YJ-oAAC7BEAAgrKeUirYZDwzJ0lPS8E'
    r'CAACAgIA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IAAxkBAAEIfbBkL-oTJzsGofBaZBaWL3El4oWULQAChxIAAuYWgEjOLbzKOt36-y8E'
]

API_TOKEN = 'TOKEN'

bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)

@dp.message_handler(commands=['start'])
async def cmd_start(message: types.Message):
    for i in range(len(stickerpack)):
     await message.answer_sticker(stickerpack[i])


if __name__ == '__main__':
    executor.start_polling(dp, skip_updates=True)

После отправки /start выдает следующий трейсбэк:
Traceback (most recent call last):
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 415, in _process_polling_updates
    for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 235, in process_updates
    return await asyncio.gather(*tasks)
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 256, in process_update
    return await self.message_handlers.notify(update.message)
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\main.py", line 56, in cmd_start
    await message.answer_sticker(stickerpack[i])
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\types\message.py", line 1405, in answer_sticker
    return await self.bot.send_sticker(
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\bot\bot.py", line 3362, in send_sticker
    result = await self.request(api.Methods.SEND_STICKER, payload, files)
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\bot\base.py", line 236, in request
    return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files,
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\bot\api.py", line 140, in make_request
    return check_result(method, response.content_type, response.status, await response.text())
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\bot\api.py", line 115, in check_result
    exceptions.BadRequest.detect(description)
  File "C:\Users\Maksim\PycharmProjects\oxxxybot\venv\lib\site-packages\aiogram\utils\exceptions.py", line 141, in detect
    raise cls(description)
aiogram.utils.exceptions.BadRequest: Wrong remote file identifier specified: wrong string length

Что я делаю не так и как сделать так, чтобы все работало?
  • Вопрос задан
  • 466 просмотров
Подписаться 1 Простой Комментировать
Пригласить эксперта
Ответы на вопрос 1
@mmmxi
await answer.animation('token')
Ответ написан
Ваш ответ на вопрос

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

Похожие вопросы