I want to forward messages from other telegram channels to my channel without being an admin of the other channels.
This code below does not work because I can't add the bot to other channel.
from aiogram import Bot, types, Dispatcher, executor
bot = Bot(token='mybottoken')
dp = Dispatcher(bot)
@dp.message_handler(content_types=types.ContentType.ANY)
async def copy_all_messages(message: types.Message):
from_chat_id = message.chat.id # the ID of the channel from where messages are copied
to_chat_id = '-##############' # the ID of the channel where messages are pasted
message_id = message.message_id # the ID of the message to be copied
await bot.copy_message(chat_id=to_chat_id, from_chat_id=from_chat_id, message_id=message_id)
if __name__ == '__main__':
executor.start_polling(dp)
in order to forward a message from the channel with the author's name, you need to use this code
if the task is to forward a message from a channel in which the bot cannot be added, here is the solution
the bot api does not allow you to forward a message from a channel to which the bot does not have access. so, you need to use the MTProto library, I can suggest the telethon and pyrogram libraries