Skip to content

Commit

Permalink
Upd steps & download example
Browse files Browse the repository at this point in the history
  • Loading branch information
JrooTJunior committed Jul 24, 2017
1 parent ffbb891 commit b687a86
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions examples/steps_and_downloading_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from aiogram.dispatcher import Dispatcher
from aiogram.types import ContentType

API_TOKEN = 'BOT TOKEN HERE'
API_TOKEN = TOKEN = 'BOT TOKEN HERE'

logging.basicConfig(level=logging.INFO)

Expand Down Expand Up @@ -45,16 +45,17 @@ async def handle_bad_message(msg: types.Message):
return await message.reply('Canceled.')

# 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:
# photo = io.BytesIO()
# await bot.download_file(msg.sticker.file_id, photo)
# Or use filename for download file to filesystem:
# await bot.download_file(msg.sticker.file_id, 'sticker.webp')

# Send photo to user
await bot.send_photo(message.chat.id, photo, caption=msg.sticker.emoji,
reply_to_message_id=message.message_id)
# Send document to user
await bot.send_document(message.chat.id, photo, caption=msg.sticker.emoji,
reply_to_message_id=message.message_id)


async def main():
Expand Down

0 comments on commit b687a86

Please sign in to comment.