luckydonald / pytg

Python package that wraps around Telegram messenger CLI. Send and receive messages, and more.
MIT License
369 stars 76 forks source link

NoResponse: [disable_preview] load_document #126

Open yahyapour opened 6 years ago

yahyapour commented 6 years ago

The problem

hi thanks for your good liberary i have a problem in downloading media ( video /photo ) my environment is : ubuntu / python3

this is my code :

sender = Sender(host="localhost", port=4458)
sender.load_document(u"01000000d82627079bba04000000000050678a898b11111a")

i even try in cli command and it downloads correctly and even with load_video has the same problem

Expected behaviour

Traceback (most recent call last): File "receiver.py", line 29, in sender.load_document(u"01000000d82627079bba04000000000050678a898b11111a") File "/usr/local/lib/python3.5/dist-packages/pytg/sender.py", line 630, in command_alias return self.execute_function(command_name, *args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/pytg/sender.py", line 318, in execute_function result = self._do_send(request, answer_timeout=result_timeout, retry_connect=retry_connect) File "/usr/local/lib/python3.5/dist-packages/pytg/sender.py", line 527, in _do_send raise NoResponse(command) pytg.exceptions.NoResponse: [disable_preview] load_document 01000000d82627079bba04000000000050678a898b11111a

thanks

yahyapour commented 6 years ago

i even try with a new id and i get this error:

Traceback (most recent call last): File "receiver.py", line 30, in sender.load_document(u'01000000d82627079dba04000000000050678a898b11111a') File "/usr/local/lib/python3.5/dist-packages/pytg/sender.py", line 630, in command_alias return self.execute_function(command_name, *args, **kwargs) File "/usr/local/lib/python3.5/dist-packages/pytg/sender.py", line 351, in execute_function return result_parser(message) File "/usr/local/lib/python3.5/dist-packages/pytg/result_parser.py", line 74, in downloaded_file raise IllegalResponseException("Has no valid event attribute.") pytg.exceptions.IllegalResponseException: Has no valid event attribute.

Ventosinos commented 2 years ago

Hi,

I am using Raspbian and I also want to dowload media with pytg, but I couldnt. However, I can tell you some things that worked for me.

  1. The ID that comes on message.id isn't the actual message id. It is the message sender's ID
  2. I experimented with telegram API and the message ID seems to be an integer begining with 1 for the first message. It doesn't depend on the sender, so if you get messages from different peers, the id will increase. I DIDN'T TEST IT ON CHANNELS OR GROUPS, ONLY WITH PEERS,SO I DONT KNOW IF IT FOLLOWS THE SAME RULE FOR THEM
  3. I could't find a way to get message id from message attributes. Please, if you know how to do this tell me. I alreade enabled message ids when starting the telegram client, but i couldn't find them

I hope that my experience help somebody. And if someone knows the way or has a script for saving pictures with pytg I would be very happy