V
V
vanproskur2020-05-12 20:03:11
Python
vanproskur, 2020-05-12 20:03:11

How to bring telegram bot and json id to work?

Firstly, I found out the id of the picture in the @ShowJsonBot bot - I just sent him a picture
. He answered me:

Tyk
{
"update_id": 923321360,
"message": {
"message_id": 300754,
"from": {
"id": 573039932,
"is_bot": false,
"first_name": "๖ۣIvan",
"last_name": "๖ۣProskuriakov",
"username": "KaliCoder",
"language_code": "ru"
},
"chat": {
"id": 573039932,
"first_name": "๖ۣIvan",
"last_name": "๖ۣProskuriakov",
"username": "KaliCoder",
"type": "private"
},
"date": 1589302557,
"photo": [
{
"file_id": "AgACAgIAAxkBAAEEltJeutUdhT8O4I1-wqdgu0q76reFywACbK0xG6f60Eny6eyF3sUlXCczepEuAAMBAAMCAANtAAMDIgMAARkE",
"file_unique_id": "AQADJzN6kS4AAwMiAwAB",
"file_size": 18828,
"width": 320,
"height": 320
},
{
"file_id": "AgACAgIAAxkBAAEEltJeutUdhT8O4I1-wqdgu0q76reFywACbK0xG6f60Eny6eyF3sUlXCczepEuAAMBAAMCAAN4AAMBIgMAARkE",
"file_unique_id": "AQADJzN6kS4AAwEiAwAB",
"file_size": 38715,
"width": 640,
"height": 640
}
]
}
}


After that I wrote the following code:
import random
import asyncio
import logging

from aiogram import Bot, types
from aiogram.utils import executor
from aiogram.utils.emoji import emojize
from aiogram.dispatcher import Dispatcher
from aiogram.types.message import ContentType
from aiogram.utils.markdown import text, bold, italic, code, pre
from aiogram.types import ParseMode, InputMediaPhoto, InputMediaVideo, ChatActions

from config import *

logging.basicConfig(format=u'%(filename)s [ LINE:%(lineno)+3s ]#%(levelname)+8s [%(asctime)s]  %(message)s',
                    level=logging.INFO)

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

@dp.message_handler(commands=['test'])
async def process_photo_command(msg: types.Message):
    await bot.send_photo(msg.from_user.id, 'AQADJzN6kS4AAwEiAwAB', reply_to_message_id=msg.message_id )

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


And he answered me with an error:
Tyk
aiogram.utils.exceptions.BadRequest: Wrong remote file identifier specified: can't unserialize it. wrong last symbol

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question