Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MessageLocation breaks fetchThreadMessages() #392

Closed
darylkell opened this issue Feb 10, 2019 · 4 comments
Closed

MessageLocation breaks fetchThreadMessages() #392

darylkell opened this issue Feb 10, 2019 · 4 comments

Comments

@darylkell
Copy link
Contributor

Description of the problem

Thanks for the great library!

Was working swimmingly until I added a MessageLocation to the test thread. Now provides the error below as it fetchThreadMessages(thread).
I have not tested a MessageLiveLocation in the test thread.

The particular location it failed on (url variable in graphql_to_extensible_attachment()) is:
https://l.facebook.com/l.php?u=https%3A%2F%2Fwww.bing.com%2Fmaps%2Fdefault.aspx%3Fv%3D2%26pc%3DFACEBK%26mid%3D8100%26where1%3DHelena%2BValley%252C%2BPerth%252C%2BWestern%2BAustralia%2B6155%26FORM%3DFBKPL1%26mkt%3Den-GB&h=AT1XzJ_ST9Xlk863CIHbJ05kI6BdeHPyfPJf_keuBNjFZR4iqKAQIL8DBqVKiGNmZHD3xnUkj4qVASGOD_2vyu9zifMRGN6nJvCFNSjsUAUvtxcgNx5DWq6uuqviewuP&s=1

Traceback

Traceback (most recent call last):
  File "C:/Users/D-PC/Google Drive/Work/Projects/99 - Other/FBchat/Facebook_message_download-master/Message_windows.py", line 307, in <module>
    do_rest(thread)
  File "C:/Users/D-PC/Google Drive/Work/Projects/99 - Other/FBchat/Facebook_message_download-master/Message_windows.py", line 146, in do_rest
    messages = client.fetchThreadMessages(thread_id=thread_id, limit=1000, before=timestamp)
  File "C:\Program Files\Python370\lib\site-packages\fbchat\client.py", line 1105, in fetchThreadMessages
    for message in j["message_thread"]["messages"]["nodes"]
  File "C:\Program Files\Python370\lib\site-packages\fbchat\client.py", line 1105, in <listcomp>
    for message in j["message_thread"]["messages"]["nodes"]
  File "C:\Program Files\Python370\lib\site-packages\fbchat\graphql.py", line 395, in graphql_to_message
    attachment = graphql_to_extensible_attachment(message["extensible_attachment"])
  File "C:\Program Files\Python370\lib\site-packages\fbchat\graphql.py", line 148, in graphql_to_extensible_attachment
    ).split(", ")
ValueError: too many values to unpack (expected 2)

Environment information

  • Python version 3.7.1
  • fbchat version 1.6.3
@darylkell
Copy link
Contributor Author

I think this was a Facebook issue - there was some discrepancy between what it was showing in the thread preview, and where it was actually linking. Perhaps some corruption of data. I deleted the MessageLocation from the thread, sent another, and it no longer throws an exception.

Still, I'm glad I got to send a thank you message for the library. Great work!

@madsmtm
Copy link
Member

madsmtm commented Feb 11, 2019

Well, it's probably still something we could take into account, and not throw an exception. So I'll probably reopen this for a while 😉

@darylkell
Copy link
Contributor Author

Well, it's probably still something we could take into account, and not throw an exception. So I'll probably reopen this for a while 😉

That'd be great. I came up against the error again today - deleting older locations isn't feasible in every case.

@darylkell
Copy link
Contributor Author

line 138, graphql.py
def graphql_to_extensible_attachment(a):

It's not getting the expected co-ords separated by a comma. On the web, the location has the text "Little Stanley St, South Brisbane, Queensland 4101" under the image of the location. This is the string being returned on line 146, so it fails when splitting by comma as it has 3 strings to store into only 2 variables (latitude, and longitude).

If I split the string into two variables by removing the last comma from the string, it would then also fail of course a couple of lines down when the LocationAttachment object being created tries to turn the strings into a float.
Rather than me hack at it, you might have an idea?

I'm only a rookie, but I hope I've helped narrow it down to a fix. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants