danielcardeenas / whatsapp-framework

⚗️Whatsapp python api
1.16k stars 362 forks source link

Error receiving vCard message #143

Open JosemariC opened 6 years ago

JosemariC commented 6 years ago

Hello, when the bot receives a message of type vCard, it fails with the following error:

AttributeError: 'VCardMediaMessageProtocolEntity' object has no attribute 'getBody'

How can I fix or ignore (not process) those messages that are not just text?

Best regards,

JosemariC commented 6 years ago

Can someone help me with this please? At least how to ignore this type of messages received.

Thank you very much,

jhonarodriguez commented 6 years ago

I can not solve it but I found a fix so that no errors come out.

I'll explain my case, I use an Amazon AMI Linux server.

Go to the file /usr/local/lib/python3.5/site-packages/yowsup2-2.5.2-py3.5.egg/yowsup/layers/axolotl/layer_receive.py

Find the method called

parseAndHandleMessageProto()

Search the condition:

elif m.HasField("contact_message"):

Comment the line:

self.handleContactMessage(node, m.contact_message)

and add on it the following line

self.handleConversationMessage(node, 'MsnNoAvalible')

This will make every time you share a contact to the bot, it becomes a text message with the message "MsnNoAvalible".

You only have to do in the module, validate that if the message "MsnNoAvalible" comes, give an answer something.

In this same file, you can fix the error when sending documents, videos, audios, or share the location in real time, among others.

Remember that every time there is an update of the github framework, and you download the repository and run the ./setup.py command, it returns the file to the original state.

Save the file already working as a backup.

I hope it works for you

JosemariC commented 6 years ago

Great @elchory96 ! It has worked. I really appreciate your help.

I take this opportunity to ask about how to send a vCard type message from the bot. It's possible? What would be the correct way to do it?

Thank you very much and best regards,

jhonarodriguez commented 6 years ago

Yes, it is possible but it takes a little more work, I finish my work schedule and suddenly look at this topic.

JosemariC commented 6 years ago

Hi @elchory96 , any ideas on which to start?

Thank you very much!