mukulhase / WebWhatsapp-Wrapper

An API for sending and receiving messages over web.whatsapp [Working as of 18th May 2018]
https://webwhatsapi.readthedocs.io/en/latest/
MIT License
2.04k stars 794 forks source link

How to send message to group #930

Closed bsde1234 closed 4 years ago

bsde1234 commented 4 years ago

I used following code to send message to group

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 = "mygroupidwhereIadmin"  # Phone number with country code
    phone_whatsapp = "{}@c.us".format(phone_safe)  # WhatsApp Chat ID
    message = "Testing a media sender!"  # The caption sent under the image, optional

    driver.send_message_to_id(
         phone_whatsapp, message
    )  # 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.")

It says success but no message sent to group. I changed phone_whatsapp = "{}@c.us".format(phone_safe) to phone_whatsapp = "{}@g.us".format(phone_safe) but not worked. I used the group id that is in the group chat invite code

marcelocecin commented 4 years ago

try to get the group ID by monitoring the receipt of any messages usually the group id is the full international format number of who created the group (country code + the area code + phone number) - random number @ g.us fictional example: 12345678901-2345678901@g.us then you can test the command, using the real id:

driver.send_message_to_id("12345678901-2345678901@g.us","Testing a message sender!")
bsde1234 commented 4 years ago

worked

avilabss commented 4 years ago

try to get the group ID by monitoring the receipt of any messages usually the group id is the full international format number of who created the group (country code + the area code + phone number) - random number @ g.us fictional example: 12345678901-2345678901@g.us then you can test the command, using the real id:

driver.send_message_to_id("12345678901-2345678901@g.us","Testing a message sender!")

How can I monitor the receipt of messages?

marcelocecin commented 4 years ago

https://github.com/mukulhase/WebWhatsapp-Wrapper/issues/669