aahnik / tgcf

The ultimate tool to automate custom telegram message forwarding. Live-syncer, Auto-poster, backup-bot, cloner, chat-forwarder, duplicator, ... Call it whatever you like! tgcf can fulfill your custom needs.
https://github.com/aahnik/tgcf/wiki
MIT License
1.31k stars 783 forks source link

Forward content when channel restrict forward content #420

Closed Blackflexxy closed 1 year ago

Blackflexxy commented 1 year ago

If private channel have turned on function "Restrict saving content" text messages is forwarding, but isn't forwarding messages with photos and videos, there's log:

│    845 │   │   │   │   │   caption=message.message,                                                       │           
                             │                                                                                                           │           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/telethon/client/uploads.py:412 in send_file       │           
                             │                                                                                                           │           
                             │   409 │   │   │   schedule_date=schedule, clear_draft=clear_draft,                                        │           
                             │   410 │   │   │   background=background                                                                   │           
                             │   411 │   │   )                                                                                           │           
                             │ ❱ 412 │   │   return self._get_response_message(request, await self(request), entity)                     │           
                             │   413 │                                                                                                   │           
                             │   414 │   async def _send_album(self: 'TelegramClient', entity, files, caption='',                        │           
                             │   415 │   │   │   │   │   │     progress_callback=None, reply_to=None,                                    │           
                             │                                                                                                           │           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/telethon/client/users.py:30 in __call__           │           
                             │                                                                                                           │           
                             │    27                                                                                                     │           
                             │    28 class UserMethods:                                                                                  │           
                             │    29 │   async def __call__(self: 'TelegramClient', request, ordered=False,                              │           
                             │       flood_sleep_threshold=None):                                                                        │           
                             │ ❱  30 │   │   return await self._call(self._sender, request, ordered=ordered)                             │           
                             │    31 │                                                                                                   │           
                             │    32 │   async def _call(self: 'TelegramClient', sender, request, ordered=False,                         │           
                             │       flood_sleep_threshold=None):                                                                        │           
                             │    33 │   │   if flood_sleep_threshold is None:                                                           │           
                             │                                                                                                           │           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/telethon/client/users.py:84 in _call              │           
                             │                                                                                                           │           
                             │    81 │   │   │   │   │   else:                                                                           │           
                             │    82 │   │   │   │   │   │   return results                                                              │           
                             │    83 │   │   │   │   else:                                                                               │           
                             │ ❱  84 │   │   │   │   │   result = await future                                                           │           
                             │    85 │   │   │   │   │   self.session.process_entities(result)                                           │           
                             │    86 │   │   │   │   │   self._entity_cache.add(result)                                                  │           
                             │    87 │   │   │   │   │   return result                                                                   │           
                             ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯           
                             ChatForwardsRestrictedError:  (caused by SendMediaRequest)                                                              
                    ERROR     (caused by SendMediaRequest)                                                                                 past.py:81
                             ╭──────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────╮           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/tgcf/past.py:67 in forward_job                    │           
                             │                                                                                                           │           
                             │   64 │   │   │   │   │   for d in dest:                                                                   │           
                             │   65 │   │   │   │   │   │   if message.is_reply and r_event_uid in st.stored:                            │           
                             │   66 │   │   │   │   │   │   │   tm.reply_to = st.stored.get(r_event_uid).get(d)                          │           
                             │ ❱ 67 │   │   │   │   │   │   fwded_msg = await send_message(d, tm)                                        │           
                             │   68 │   │   │   │   │   │   st.stored[event_uid].update({d: fwded_msg.id})                               │           
                             │   69 │   │   │   │   │   tm.clear()                                                                       │           
                             │   70 │   │   │   │   │   last_id = message.id                                                             │           
                             │                                                                                                           │           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/tgcf/utils.py:43 in send_message                  │           
                             │                                                                                                           │           
                             │   40 │   │   )                                                                                            │           
                             │   41 │   │   return message                                                                               │           
                             │   42 │   tm.message.text = tm.text                                                                        │           
                             │ ❱ 43 │   return await client.send_message(recipient, tm.message, reply_to=tm.reply_to)                    │           
                             │   44                                                                                                      │           
                             │   45                                                                                                      │           
                             │   46 def cleanup(*files: str) -> None:                                                                    │           
                             │                                                                                                           │           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/telethon/client/messages.py:842 in send_message   │           
                             │                                                                                                           │           
                             │    839 │   │   │                                                                                          │           
                             │    840 │   │   │   if (message.media and not isinstance(                                                  │           
                             │    841 │   │   │   │   │   message.media, types.MessageMediaWebPage)):                                    │           
                             │ ❱  842 │   │   │   │   return await self.send_file(                                                       │           
                             │    843 │   │   │   │   │   entity,                                                                        │           
                             │    844 │   │   │   │   │   message.media,                                                                 │           
                             │    845 │   │   │   │   │   caption=message.message,                                                       │           
                             │                                                                                                           │           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/telethon/client/uploads.py:412 in send_file       │           
                             │                                                                                                           │           
                             │   409 │   │   │   schedule_date=schedule, clear_draft=clear_draft,                                        │           
                             │   410 │   │   │   background=background                                                                   │           
                             │   411 │   │   )                                                                                           │           
                             │ ❱ 412 │   │   return self._get_response_message(request, await self(request), entity)                     │           
                             │   413 │                                                                                                   │           
                             │   414 │   async def _send_album(self: 'TelegramClient', entity, files, caption='',                        │           
                             │   415 │   │   │   │   │   │     progress_callback=None, reply_to=None,                                    │           
                             │                                                                                                           │           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/telethon/client/users.py:30 in __call__           │           
                             │                                                                                                           │           
                             │    27                                                                                                     │           
                             │    28 class UserMethods:                                                                                  │           
                             │    29 │   async def __call__(self: 'TelegramClient', request, ordered=False,                              │           
                             │       flood_sleep_threshold=None):                                                                        │           
                             │ ❱  30 │   │   return await self._call(self._sender, request, ordered=ordered)                             │           
                             │    31 │                                                                                                   │           
                             │    32 │   async def _call(self: 'TelegramClient', sender, request, ordered=False,                         │           
                             │       flood_sleep_threshold=None):                                                                        │           
                             │    33 │   │   if flood_sleep_threshold is None:                                                           │           
                             │                                                                                                           │           
                             │ /home/ubuntu/my-tgcf/.venv/lib/python3.10/site-packages/telethon/client/users.py:84 in _call              │           
                             │                                                                                                           │           
                             │    81 │   │   │   │   │   else:                                                                           │           
                             │    82 │   │   │   │   │   │   return results                                                              │           
                             │    83 │   │   │   │   else:                                                                               │           
                             │ ❱  84 │   │   │   │   │   result = await future                                                           │           
                             │    85 │   │   │   │   │   self.session.process_entities(result)                                           │           
                             │    86 │   │   │   │   │   self._entity_cache.add(result)                                                  │           
                             │    87 │   │   │   │   │   return result                                                                   │           
                             ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────╯           
                             ChatForwardsRestrictedError:  (caused by SendMediaRequest) 

There was similar issue on Telethon: https://github.com/LonamiWebs/Telethon/issues/3237 Can you implement this feature?

MobCode100 commented 1 year ago

Please close this issue. It is not the bot's fault as the action is prohibited by Telegram's Terms of Service: https://github.com/aahnik/tgcf/issues/467#issuecomment-1627432864

Thank you :)