is there an example to send multimedia files, images, sound etc?
Hey @mikhakhaldea,
There is no example yet but the function send_media is coded as you can see on __init__.py (L:550) or wapi.js.
I've made a very quick and simple example, hope it helps you:
from webwhatsapi import WhatsAPIDriver
from webwhatsapi.objects.message import Message
driver = WhatsAPIDriver(loadstyles=False)
print("Waiting for QR")
driver.wait_for_login()
print("Bot started")
try:
phone_safe = "1122333333333" # Phone number with country code
phone_whatsapp = "{}@c.us".format(phone_safe) # WhatsApp Chat ID
image_path = "image.png" # Local path file
caption = "Testing a media sender!" # The caption sent under the image, optional
driver.send_media(image_path, phone_whatsapp, caption) # Expected send_media(self, path, chatid, caption)
print("Media file was successfully sent to {}".format(phone_safe))
except:
print("Error while trying to send the midia file.")
This function expects the chat ID, a local media path and _optionally_ a caption.
You can get the media from a URL using some libraries like requests, urllib, etc. but that depends a lot on which Python version you are using.
thank you very much @lfdelphino.
Most helpful comment
Hey @mikhakhaldea,
There is no example yet but the function
send_mediais coded as you can see on __init__.py (L:550) or wapi.js.I've made a very quick and simple example, hope it helps you:
This function expects the chat ID, a local media path and _optionally_ a caption.
You can get the media from a URL using some libraries like requests, urllib, etc. but that depends a lot on which Python version you are using.