Open alirezaevil81 opened 6 months ago
Hi @alirezaevil81
Could you provide your code that returns this error?
Hello, I'm encountering the same error. The code is quite straightforward:
from instagrapi import Client
cl = Client()
cl.login("USER", "PWD")
cl.direct_send('How are you?', user_ids=[cl.user_id])
Error:
332 if xma_media_share:
333 data["xma_share"] = extract_media_v1_xma(xma_media_share[0])
--> 335 data['timestamp'] = datetime.datetime.fromtimestamp(data['timestamp'] // 1_000_000)
336 data['user_id'] = str(data['user_id'])
338 return DirectMessage(**data)
TypeError: unsupported operand type(s) for //: 'str' and 'int'
refering to line 313 in extractor.py , function extract_reply_mesage :
wouldn't the following modification solve the problem ? int(data["timestamp"])
instead of data["timestamp"]
Make sure to do a pip install instagrapi --upgrade
Then in extractors.py change this in line 335 : data['timestamp'] = datetime.datetime.fromtimestamp(data['timestamp'] // 1_000_000) to this : data['timestamp'] = datetime.datetime.fromtimestamp(int(data['timestamp']) // 1_000_000)
Also the next line seems to have a typo so change this data['user_id'] = str(data['user_id']) which returns a keyerror 'user_id'
change to this : data['user_id'] = str(data['id'])
Happy coding and good luck.
@instaprime, if you already have a working solution, would you mind creating a PR for this? Then, it can get integrated in the code base, properly.
I get this error after using any direct sending method