K
K
kurmyu2021-12-23 09:58:38
Python
kurmyu, 2021-12-23 09:58:38

Copying a message from a telegram channel to a telegram bot?

I'm trying to make the bot copy messages from the telegram channel.
It gives a Message not found error, although they are definitely there, the channel id is definitely correct.

I'm just trying to make the bot issue a test along with the picture.

@dp.message_handler(filters.Text(contains=animeop, ignore_case=True))
@dp.message_handler(filters.Text(contains=opanime, ignore_case=True))
@dp.message_handler(commands="onepiece")
async def with_pureeop(message: types.Message, content=-1001718899350, content_max=4):
    keyboardop = types.ReplyKeyboardMarkup(resize_keyboard=True)
    buttons = ["Ван Пис"]
    keyboardop.add(*buttons)
    await bot.copy_message(message.message_id, content, randint(2, content_max), reply_to_message_id=message.message_id, reply_markup=keyboardop)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-12-23
@SoreMix

In such a mess, nothing is clear, but at least you are passing the wrong parameters to copy_message.
The method accepts chat_id, from_chat_id and message_id. You passed a message_id, some chat Id and a random number
https://core.telegram.org/bots/api#copymessage

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question