Advertisement
disk6969

telethon Gallery copy

Aug 9th, 2023 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. @user_client.on(events.NewMessage(chats=None))
  2. @user_client.on(events.Album())
  3. async def copy_to_channel(event):
  4.     try:
  5.         chat_id = int(str(event.chat_id)[4:])
  6.         chat = await user_client.get_entity(chat_id)
  7.         if not chat.broadcast or chat_id not in await get_unique_donor_ids():
  8.             return
  9.         to_channels = await get_channels_with_autoposting(chat_id)
  10.         gallery = getattr(event, 'messages', None)
  11.          
  12.         if not gallery and event.grouped_id:
  13.             return
  14.         for to_channel in to_channels:
  15.             if gallery:
  16.                 await user_client.send_file(to_channel, gallery)
  17.             else:
  18.                 await user_client.send_message(to_channel, event.message)
  19.     except:
  20.         pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement