bot = Bot(token=TOKEN)
dp = Dispatcher()
chat_ids = []
async def check_if_bot_is_admin(chat_id):
member = await bot.get_chat_member(chat_id, bot.id)
resp = member.status
return resp
@dp.message(F.photo)
async def handle_photo(message: types.Message):
for group_id in chat_ids:
is_admin = await check_if_bot_is_admin(group_id)
if message.chat.type == 'private' and is_admin:
await message.copy_to(chat_id=group_id)
async def main():
await dp.start_polling(bot)
As you can see, after running this code, when you send to any image to bot as private message, the bot starts to the send to group that in list of chat_ids(and before it check if it has admin). But now I need to fill this chat_ids list manually. I can’t figure out how to automatically append any id of gorup after bot is added to that group.
My aim from making this bot is to make sure that after sending to bots private message any image it send the image to all group that it has admin
Yunusbek Yusupov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.