mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-10 17:53:17 +00:00
Upd steps & download example
This commit is contained in:
parent
ffbb89100c
commit
b687a867b7
1 changed files with 6 additions and 5 deletions
|
|
@ -5,7 +5,7 @@ from aiogram import Bot, types
|
||||||
from aiogram.dispatcher import Dispatcher
|
from aiogram.dispatcher import Dispatcher
|
||||||
from aiogram.types import ContentType
|
from aiogram.types import ContentType
|
||||||
|
|
||||||
API_TOKEN = 'BOT TOKEN HERE'
|
API_TOKEN = TOKEN = 'BOT TOKEN HERE'
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
||||||
|
|
@ -45,16 +45,17 @@ async def save_sticker(message: types.Message):
|
||||||
return await message.reply('Canceled.')
|
return await message.reply('Canceled.')
|
||||||
|
|
||||||
# Download file to memory (io.BytesIO)
|
# Download file to memory (io.BytesIO)
|
||||||
photo = await bot.download_file(msg.sticker.file_id)
|
photo = await bot.download_file_by_id(msg.sticker.file_id)
|
||||||
|
|
||||||
# And you can use other syntax:
|
# And you can use other syntax:
|
||||||
# photo = io.BytesIO()
|
# photo = io.BytesIO()
|
||||||
# await bot.download_file(msg.sticker.file_id, photo)
|
# await bot.download_file(msg.sticker.file_id, photo)
|
||||||
# Or use filename for download file to filesystem:
|
# Or use filename for download file to filesystem:
|
||||||
# await bot.download_file(msg.sticker.file_id, 'sticker.webp')
|
# await bot.download_file(msg.sticker.file_id, 'sticker.webp')
|
||||||
|
|
||||||
# Send photo to user
|
# Send document to user
|
||||||
await bot.send_photo(message.chat.id, photo, caption=msg.sticker.emoji,
|
await bot.send_document(message.chat.id, photo, caption=msg.sticker.emoji,
|
||||||
reply_to_message_id=message.message_id)
|
reply_to_message_id=message.message_id)
|
||||||
|
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue