ma-nish


Namema-nish JSON
Version 1.3.2 PyPI version JSON
download
home_pagehttps://github.com/t0mer/ma-nish
Summarymanish is an unofficial python wrapper for Whatsapp cloud api
upload_time2024-12-01 09:37:43
maintainerNone
docs_urlNone
authorTomer Klein
requires_pythonNone
licenseMIT
keywords meta ma-nish facebook whatsapp
VCS
bugtrack_url
requirements certifi charset-normalizer decorator geographiclib geopy idna pillow python-dotenv requests requests-toolbelt urllib3 validators
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # manish
WhatsApp has now opened up its API so you no longer have to go through a partner to send and receive WhatsApp messages!
MaNish is an Unofficial python wrapper to [WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api)

## Features supported
1. Sending Messages
2. Sending Media (images, audio, video and documents)
3. Sending Stickers
3. Sending Location
4. Sending Contacts
5. Sending Buttons
6. Sending Template messages
7. Parsing messages and media received (Webhook)

## Components and Frameworks used in manish
* [Loguru](https://pypi.org/project/loguru/)
* [Requests ](https://pypi.org/project/requests/)
* [requests-toolbelt](https://pypi.org/project/requests-toolbelt/)
* [python-dotenv](https://pypi.org/project/python-dotenv/)
* [validators](https://pypi.org/project/validators/)
* [geopy](https://pypi.org/project/geopy/)
* [Pillow](https://pypi.org/project/Pillow/)
* [Uvicorn](https://pypi.org/project/uvicorn/)
* [fastapi](https://pypi.org/project/fastapi/)
* [jinja2](https://pypi.org/project/Jinja/)


## Limitations
* 1000 free messages per month (Free tier)
* It is only possible to send messages other than templates after the target phone responds to an initial message (Unless you use Template messages)
* You can't send message to a group


## Getting started
To get started with **manish**, you have to firstly install the libary either directly or using *pip*.

### Installation from source

Use git to clone or you can also manually download the project repository just as shown below;

```bash
$ git clone https://github.com/t0mer/ma-nish/
$ cd ma-nish
ma-nish $ python setup.py install 
```

### Installing from PyPi

```bash
# For Windows 

pip install  --upgrade ma-nish

#For Linux | MAC 

pip3 install --upgrade ma-nish
```


## Setting up the environment
### Set Up Meta App

First you’ll need to follow the [instructions on this page](https://developers.facebook.com/docs/whatsapp/cloud-api/get-started) to:

* Register as a Meta Developer
* Enable two-factor authentication for your account
* Create a Meta App – you need to create a Business App for WhatsApp

Once you’ve done that, go to your app and set up the WhatsApp product.

[![New app](https://techblog.co.il/wp-content/uploads/2022/12/new-app.png "New App")](https://techblog.co.il/wp-content/uploads/2022/12/new-app.png "New App")

You’ll be given a temporary access token and a Phone Number ID, note these down as you’ll need them later. Set up your own phone number as a recipient and you can have a go at sending yourself a test message:

[![Getting started](https://techblog.co.il/wp-content/uploads/2022/12/test-number.png "Getting started")](https://techblog.co.il/wp-content/uploads/2022/12/test-number.png "Getting started")

### Set Up Message Template

In the test message above, you used the **hello_world** template. You’ll need to set up your own template for your own purposes. If you go to [“Message Templates”](https://business.facebook.com/wa/manage/message-templates/) in the WhatsApp manager you can build your own templates.

In the following example, i created a template for my smat home. The template header if fixed and so is the footer. in the body i added variable for dynamic text:

[![Smart Home Template](https://techblog.co.il/wp-content/uploads/2022/12/my-template.png "Smart Home Template")](https://techblog.co.il/wp-content/uploads/2022/12/my-template.png "Smart Home Template")


Once you're done with the above ,you're ready to start send messages using **manish**.

## Authentication
Before you can send messages, you need to authenticate your application using the **```phone_number_id```** and **```Token```** of your test number.

```python
>>> from manish import MaNish
>>> manish = MaNish('TOKEN',  phone_number_id='xxxxxxxxxx')
```

One your app is authenticated, you can start sending messages.
As mentioned above, it is only possible to send messages other than templates after the target phone responds to an initial message.

## Sending Messanges

This method can be used for sending simple text messages.

```python
>>> manish.send_message(
        message='Your message',
        recipient_id='97250xxxxxxx'
     )
```
***Mobile should include country code without the + symbol***

## Sending Media
When sending media:
* Images
* Video
* Audio
* Document
* Gif

You can either specify:
* URL for the media.
* Local file.

## Sending Image

```python
>>> manish.send_image(
        image="https://i.imgur.com/COXQuEz.jpeg",
        recipient_id="97250xxxxxxx",
    )
```

## Sending Video
```python

>>> manish.send_video(
        video="https://user-images.githubusercontent.com/4478920/200173402-8a8343c3-afc2-4341-86ea-c833bed98a9a.mp4",
        recipient_id="97250xxxxxxx",
    )
```

## Sending Audio

```python
>>> manish.send_audio(
        audio="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-9.mp3",
        recipient_id="97250xxxxxxx",
    )
```

## Sending Document

```python
>>> messenger.send_document(
        document="https://www.africau.edu/images/default/sample.pdf",
        recipient_id="97250xxxxxxx",
    )
```

## Sending Sticker
Cloud API: Static and animated third-party outbound stickers are supported in addition to all types of inbound stickers. A static sticker needs to be 512x512 pixels and cannot exceed 100 KB. An animated sticker must be 512x512 pixels and cannot exceed 500 KB.

When sending from local file, the app will automatically convert the image to the supported format.


```python
>>> manish.send_sticker(
        image="https://i.imgur.com/COXQuEz.webp",
        recipient_id="97250xxxxxxx",
    )
```

## Sending Location
The Location message object requires **longitude** and **latitude**, but you can also send real address and manish will translate the address to coordinates and send thr message.

```python
>>> from manish.location import *
>>> location = Location(address="10 Hagalil street, raanana",name="Home")
>>> manish.send_location(location = location,recipient_id="97250xxxxxxx")

```

## Sending Contact(s)
```python
>>> from manish.contact import *
>>> phones = [Phone(phone="97250xxxxxxx",type="CELL")]
>>> name = Name(formatted_name="Tomer Klein", first_name="Tomer", last_name="Klein")
>>> addresses = [Address(street="Hagalil 10", city="Raanana", zip ="123456", country="Israel")]
>>> emails = [Email("jhon.c@gmail.com")]
>>> contact = Contact(name=name,addresses=addresses,emails=emails,phones=phones)
>>> data = ContactEncoder().encode([contact])
>>> manish.send_contacts(data,"97250xxxxxxx")

```

## Sending Button(s)
```python
>>> from manish.button import *
>>> rows = []
>>> rows.append(Row("row 1","Send Mony",""))
>>> rows.append(Row("row 2","Withdraw Mony",""))
>>> sections = []
>>> sections.append(Section("iBank",rows))
>>> action = Action("Button Testing",sections)
>>> button = Button("Header Testing", "Body Testing", "Footer Testing",action)
>>> data = ButtonEncoder().encode(button)
>>> manish.send_button(data,"97250xxxxxxx")
```

## Sending Template Messages
This method allows you to send template based messages (and bypass the limitation of the ability to send message outside the 24 hours window).

Template messages can either be:
* Text Template (Can also include currency object)
* Media Template (Same as Text but with media in the header)

### Sending simple text template
```python
>>> from manish.template import *
>>> def send_template():
>>> parameter = Parameter(type="text",text = "Your Text Message")
>>> parameters = []
>>> parameters.append(parameter)
>>> body = Component(type="body",parameters=[parameter])
>>> manish.send_template(components=TemplateEncoder().encode([body]),recipient_id="97250xxxxxxx",template="smart_home_media",lang="he")
```

### Sending media template
**Media can only be attached to the header!**
```python
>>> parameter = Parameter(type="text",text = "Your Text Message")
>>> img = Media(link="https://raw.githubusercontent.com/t0mer/broadlinkmanager-docker/master/screenshots/Devices%20List.png")
>>> iparam = MediaParameter(type="image",image=img)
>>> parameters = []
>>> parameters.append(parameter)
>>> body = Component(type="body",parameters=[parameter])
>>> header = Component(type="header",parameters=[iparam])
>>> manish.send_template(components=TemplateEncoder().encode([body,header]),recipient_id="97250xxxxxxx",template="smart_home_media",lang="he")
```

## Webhook
Well, untill now you were only able to send messages. but what if you need to respond to incoming messages?
So i created [webhook](https://github.com/t0mer/ma-nish/blob/main/webhook.py) using [FastAPI](https://fastapi.tiangolo.com/). Feel free to customize and change it to fit your needs.

With this webhook you can:
* **Verify webhook** (Whatsapp cloud api require webhook token verification)
* **Get Senders Mobile Number**
* **Get Message Text from sender**
* **Get Location sent by sender**
* **Get Media (Image, Video, Audio, Document, File) sent by user**
* **Get Delivery status**

### Verify token example
```python
>>> @app.get("/", include_in_schema=False)
>>> async def verify(request: Request):
>>>    if request.query_params.get('hub.mode') == "subscribe" and request.query_params.get("hub.challenge"):
>>>        if not request.query_params.get('hub.verify_token') == VERIFY_TOKEN: #os.environ["VERIFY_TOKEN"]:
>>>            return "Verification token mismatch", 403
>>>        return int(request.query_params.get('hub.challenge'))
>>>    return "Hello world", 200
```



### Webhook usage example
```python
>>> @app.post("/", include_in_schema=False)
>>> async def webhook(request: Request):
>>>     data = await request.json()
>>>     changed_field = manish.changed_field(data)
>>>     if changed_field == "messages":
>>>         new_message = manish.get_mobile(data)
>>>         if new_message:
>>>             mobile = manish.get_mobile(data)
>>>             name = manish.get_name(data)
>>>             message_type = manish.get_message_type(data)
>>>             logger.info(
>>>                 f"New Message; sender:{mobile} name:{name} type:{message_type}"
>>>             )
>>>             if message_type == "text":
>>>                 message = manish.get_message(data)
>>>                 name = manish.get_name(data)
>>>                 logger.info("Message: %s", message)
>>>                 manish.send_message(f"Hi {name}, nice to connect with you", mobile)
>>>             elif message_type == "interactive":
>>>                 message_response = manish.get_interactive_response(data)
>>>                 intractive_type = message_response.get("type")
>>>                 message_id = message_response[intractive_type]["id"]
>>>                 message_text = message_response[intractive_type]["title"]
>>>                 logger.info(f"Interactive Message; {message_id}: {message_text}")
>>>             elif message_type == "location":
>>>                 message_location = manish.get_location(data)
>>>                 message_latitude = message_location["latitude"]
>>>                 message_longitude = message_location["longitude"]
>>>                 logger.info("Location: %s, %s", message_latitude, message_longitude)
>>>             elif message_type == "image":
>>>                 image = manish.get_image(data)
>>>                 image_id, mime_type = image["id"], image["mime_type"]
>>>                 image_url = manish.query_media_url(image_id)
>>>                 image_filename = manish.download_media(image_url, mime_type)
>>>                 logger.info(f"{mobile} sent image {image_filename}")
>>>             elif message_type == "video":
>>>                 video = manish.get_video(data)
>>>                 video_id, mime_type = video["id"], video["mime_type"]
>>>                 video_url = manish.query_media_url(video_id)
>>>                 video_filename = manish.download_media(video_url, mime_type)
>>>                 logger.info(f"{mobile} sent video {video_filename}")
>>>             elif message_type == "audio":
>>>                 audio = manish.get_audio(data)
>>>                 audio_id, mime_type = audio["id"], audio["mime_type"]
>>>                 audio_url = manish.query_media_url(audio_id)
>>>                 audio_filename = manish.download_media(audio_url, mime_type)
>>>                 logger.info(f"{mobile} sent audio {audio_filename}")
>>>             elif message_type == "file":
>>>                 file = manish.get_file(data)
>>>                 file_id, mime_type = file["id"], file["mime_type"]
>>>                 file_url = manish.query_media_url(file_id)
>>>                 file_filename = manish.download_media(file_url, mime_type)
>>>                 logger.info(f"{mobile} sent file {file_filename}")
>>>             else:
>>>                 logger.info(f"{mobile} sent {message_type} ")
>>>                 logger.info(data)
>>>         else:
>>>             delivery = manish.get_delivery(data)
>>>             if delivery:
>>>                 logger.info(f"Message : {delivery}")
>>>             else:
>>>                 logger.info("No new message")
>>>     return "ok"
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/t0mer/ma-nish",
    "name": "ma-nish",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "meta, ma-nish, facebook, whatsapp",
    "author": "Tomer Klein",
    "author_email": "tomer.klein@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/98/4b/9a55eb7882c75a51c6304ef2a204407d0a7689ec64e9bf18affdf02f6e2c/ma_nish-1.3.2.tar.gz",
    "platform": null,
    "description": "# manish\nWhatsApp has now opened up its API so you no longer have to go through a partner to send and receive WhatsApp messages!\nMaNish is an Unofficial python wrapper to [WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api)\n\n## Features supported\n1. Sending Messages\n2. Sending Media (images, audio, video and documents)\n3. Sending Stickers\n3. Sending Location\n4. Sending Contacts\n5. Sending Buttons\n6. Sending Template messages\n7. Parsing messages and media received (Webhook)\n\n## Components and Frameworks used in manish\n* [Loguru](https://pypi.org/project/loguru/)\n* [Requests ](https://pypi.org/project/requests/)\n* [requests-toolbelt](https://pypi.org/project/requests-toolbelt/)\n* [python-dotenv](https://pypi.org/project/python-dotenv/)\n* [validators](https://pypi.org/project/validators/)\n* [geopy](https://pypi.org/project/geopy/)\n* [Pillow](https://pypi.org/project/Pillow/)\n* [Uvicorn](https://pypi.org/project/uvicorn/)\n* [fastapi](https://pypi.org/project/fastapi/)\n* [jinja2](https://pypi.org/project/Jinja/)\n\n\n## Limitations\n* 1000 free messages per month (Free tier)\n* It is only possible to send messages other than templates after the target phone responds to an initial message (Unless you use Template messages)\n* You can't send message to a group\n\n\n## Getting started\nTo get started with **manish**, you have to firstly install the libary either directly or using *pip*.\n\n### Installation from source\n\nUse git to clone or you can also manually download the project repository just as shown below;\n\n```bash\n$ git clone https://github.com/t0mer/ma-nish/\n$ cd ma-nish\nma-nish $ python setup.py install \n```\n\n### Installing from PyPi\n\n```bash\n# For Windows \n\npip install  --upgrade ma-nish\n\n#For Linux | MAC \n\npip3 install --upgrade ma-nish\n```\n\n\n## Setting up the environment\n### Set Up Meta App\n\nFirst you\u2019ll need to follow the [instructions on this page](https://developers.facebook.com/docs/whatsapp/cloud-api/get-started) to:\n\n* Register as a Meta Developer\n* Enable two-factor authentication for your account\n* Create a Meta App \u2013 you need to create a Business App for WhatsApp\n\nOnce you\u2019ve done that, go to your app and set up the WhatsApp product.\n\n[![New app](https://techblog.co.il/wp-content/uploads/2022/12/new-app.png \"New App\")](https://techblog.co.il/wp-content/uploads/2022/12/new-app.png \"New App\")\n\nYou\u2019ll be given a temporary access token and a Phone Number ID, note these down as you\u2019ll need them later. Set up your own phone number as a recipient and you can have a go at sending yourself a test message:\n\n[![Getting started](https://techblog.co.il/wp-content/uploads/2022/12/test-number.png \"Getting started\")](https://techblog.co.il/wp-content/uploads/2022/12/test-number.png \"Getting started\")\n\n### Set Up Message Template\n\nIn the test message above, you used the **hello_world** template. You\u2019ll need to set up your own template for your own purposes. If you go to [\u201cMessage Templates\u201d](https://business.facebook.com/wa/manage/message-templates/) in the WhatsApp manager you can build your own templates.\n\nIn the following example, i created a template for my smat home. The template header if fixed and so is the footer. in the body i added variable for dynamic text:\n\n[![Smart Home Template](https://techblog.co.il/wp-content/uploads/2022/12/my-template.png \"Smart Home Template\")](https://techblog.co.il/wp-content/uploads/2022/12/my-template.png \"Smart Home Template\")\n\n\nOnce you're done with the above ,you're ready to start send messages using **manish**.\n\n## Authentication\nBefore you can send messages, you need to authenticate your application using the **```phone_number_id```** and **```Token```** of your test number.\n\n```python\n>>> from manish import MaNish\n>>> manish = MaNish('TOKEN',  phone_number_id='xxxxxxxxxx')\n```\n\nOne your app is authenticated, you can start sending messages.\nAs mentioned above, it is only possible to send messages other than templates after the target phone responds to an initial message.\n\n## Sending Messanges\n\nThis method can be used for sending simple text messages.\n\n```python\n>>> manish.send_message(\n        message='Your message',\n        recipient_id='97250xxxxxxx'\n     )\n```\n***Mobile should include country code without the + symbol***\n\n## Sending Media\nWhen sending media:\n* Images\n* Video\n* Audio\n* Document\n* Gif\n\nYou can either specify:\n* URL for the media.\n* Local file.\n\n## Sending Image\n\n```python\n>>> manish.send_image(\n        image=\"https://i.imgur.com/COXQuEz.jpeg\",\n        recipient_id=\"97250xxxxxxx\",\n    )\n```\n\n## Sending Video\n```python\n\n>>> manish.send_video(\n        video=\"https://user-images.githubusercontent.com/4478920/200173402-8a8343c3-afc2-4341-86ea-c833bed98a9a.mp4\",\n        recipient_id=\"97250xxxxxxx\",\n    )\n```\n\n## Sending Audio\n\n```python\n>>> manish.send_audio(\n        audio=\"https://www.soundhelix.com/examples/mp3/SoundHelix-Song-9.mp3\",\n        recipient_id=\"97250xxxxxxx\",\n    )\n```\n\n## Sending Document\n\n```python\n>>> messenger.send_document(\n        document=\"https://www.africau.edu/images/default/sample.pdf\",\n        recipient_id=\"97250xxxxxxx\",\n    )\n```\n\n## Sending Sticker\nCloud API: Static and animated third-party outbound stickers are supported in addition to all types of inbound stickers. A static sticker needs to be 512x512 pixels and cannot exceed 100 KB. An animated sticker must be 512x512 pixels and cannot exceed 500 KB.\n\nWhen sending from local file, the app will automatically convert the image to the supported format.\n\n\n```python\n>>> manish.send_sticker(\n        image=\"https://i.imgur.com/COXQuEz.webp\",\n        recipient_id=\"97250xxxxxxx\",\n    )\n```\n\n## Sending Location\nThe Location message object requires **longitude** and **latitude**, but you can also send real address and manish will translate the address to coordinates and send thr message.\n\n```python\n>>> from manish.location import *\n>>> location = Location(address=\"10 Hagalil street, raanana\",name=\"Home\")\n>>> manish.send_location(location = location,recipient_id=\"97250xxxxxxx\")\n\n```\n\n## Sending Contact(s)\n```python\n>>> from manish.contact import *\n>>> phones = [Phone(phone=\"97250xxxxxxx\",type=\"CELL\")]\n>>> name = Name(formatted_name=\"Tomer Klein\", first_name=\"Tomer\", last_name=\"Klein\")\n>>> addresses = [Address(street=\"Hagalil 10\", city=\"Raanana\", zip =\"123456\", country=\"Israel\")]\n>>> emails = [Email(\"jhon.c@gmail.com\")]\n>>> contact = Contact(name=name,addresses=addresses,emails=emails,phones=phones)\n>>> data = ContactEncoder().encode([contact])\n>>> manish.send_contacts(data,\"97250xxxxxxx\")\n\n```\n\n## Sending Button(s)\n```python\n>>> from manish.button import *\n>>> rows = []\n>>> rows.append(Row(\"row 1\",\"Send Mony\",\"\"))\n>>> rows.append(Row(\"row 2\",\"Withdraw Mony\",\"\"))\n>>> sections = []\n>>> sections.append(Section(\"iBank\",rows))\n>>> action = Action(\"Button Testing\",sections)\n>>> button = Button(\"Header Testing\", \"Body Testing\", \"Footer Testing\",action)\n>>> data = ButtonEncoder().encode(button)\n>>> manish.send_button(data,\"97250xxxxxxx\")\n```\n\n## Sending Template Messages\nThis method allows you to send template based messages (and bypass the limitation of the ability to send message outside the 24 hours window).\n\nTemplate messages can either be:\n* Text Template (Can also include currency object)\n* Media Template (Same as Text but with media in the header)\n\n### Sending simple text template\n```python\n>>> from manish.template import *\n>>> def send_template():\n>>> parameter = Parameter(type=\"text\",text = \"Your Text Message\")\n>>> parameters = []\n>>> parameters.append(parameter)\n>>> body = Component(type=\"body\",parameters=[parameter])\n>>> manish.send_template(components=TemplateEncoder().encode([body]),recipient_id=\"97250xxxxxxx\",template=\"smart_home_media\",lang=\"he\")\n```\n\n### Sending media template\n**Media can only be attached to the header!**\n```python\n>>> parameter = Parameter(type=\"text\",text = \"Your Text Message\")\n>>> img = Media(link=\"https://raw.githubusercontent.com/t0mer/broadlinkmanager-docker/master/screenshots/Devices%20List.png\")\n>>> iparam = MediaParameter(type=\"image\",image=img)\n>>> parameters = []\n>>> parameters.append(parameter)\n>>> body = Component(type=\"body\",parameters=[parameter])\n>>> header = Component(type=\"header\",parameters=[iparam])\n>>> manish.send_template(components=TemplateEncoder().encode([body,header]),recipient_id=\"97250xxxxxxx\",template=\"smart_home_media\",lang=\"he\")\n```\n\n## Webhook\nWell, untill now you were only able to send messages. but what if you need to respond to incoming messages?\nSo i created [webhook](https://github.com/t0mer/ma-nish/blob/main/webhook.py) using [FastAPI](https://fastapi.tiangolo.com/). Feel free to customize and change it to fit your needs.\n\nWith this webhook you can:\n* **Verify webhook** (Whatsapp cloud api require webhook token verification)\n* **Get Senders Mobile Number**\n* **Get Message Text from sender**\n* **Get Location sent by sender**\n* **Get Media (Image, Video, Audio, Document, File) sent by user**\n* **Get Delivery status**\n\n### Verify token example\n```python\n>>> @app.get(\"/\", include_in_schema=False)\n>>> async def verify(request: Request):\n>>>    if request.query_params.get('hub.mode') == \"subscribe\" and request.query_params.get(\"hub.challenge\"):\n>>>        if not request.query_params.get('hub.verify_token') == VERIFY_TOKEN: #os.environ[\"VERIFY_TOKEN\"]:\n>>>            return \"Verification token mismatch\", 403\n>>>        return int(request.query_params.get('hub.challenge'))\n>>>    return \"Hello world\", 200\n```\n\n\n\n### Webhook usage example\n```python\n>>> @app.post(\"/\", include_in_schema=False)\n>>> async def webhook(request: Request):\n>>>     data = await request.json()\n>>>     changed_field = manish.changed_field(data)\n>>>     if changed_field == \"messages\":\n>>>         new_message = manish.get_mobile(data)\n>>>         if new_message:\n>>>             mobile = manish.get_mobile(data)\n>>>             name = manish.get_name(data)\n>>>             message_type = manish.get_message_type(data)\n>>>             logger.info(\n>>>                 f\"New Message; sender:{mobile} name:{name} type:{message_type}\"\n>>>             )\n>>>             if message_type == \"text\":\n>>>                 message = manish.get_message(data)\n>>>                 name = manish.get_name(data)\n>>>                 logger.info(\"Message: %s\", message)\n>>>                 manish.send_message(f\"Hi {name}, nice to connect with you\", mobile)\n>>>             elif message_type == \"interactive\":\n>>>                 message_response = manish.get_interactive_response(data)\n>>>                 intractive_type = message_response.get(\"type\")\n>>>                 message_id = message_response[intractive_type][\"id\"]\n>>>                 message_text = message_response[intractive_type][\"title\"]\n>>>                 logger.info(f\"Interactive Message; {message_id}: {message_text}\")\n>>>             elif message_type == \"location\":\n>>>                 message_location = manish.get_location(data)\n>>>                 message_latitude = message_location[\"latitude\"]\n>>>                 message_longitude = message_location[\"longitude\"]\n>>>                 logger.info(\"Location: %s, %s\", message_latitude, message_longitude)\n>>>             elif message_type == \"image\":\n>>>                 image = manish.get_image(data)\n>>>                 image_id, mime_type = image[\"id\"], image[\"mime_type\"]\n>>>                 image_url = manish.query_media_url(image_id)\n>>>                 image_filename = manish.download_media(image_url, mime_type)\n>>>                 logger.info(f\"{mobile} sent image {image_filename}\")\n>>>             elif message_type == \"video\":\n>>>                 video = manish.get_video(data)\n>>>                 video_id, mime_type = video[\"id\"], video[\"mime_type\"]\n>>>                 video_url = manish.query_media_url(video_id)\n>>>                 video_filename = manish.download_media(video_url, mime_type)\n>>>                 logger.info(f\"{mobile} sent video {video_filename}\")\n>>>             elif message_type == \"audio\":\n>>>                 audio = manish.get_audio(data)\n>>>                 audio_id, mime_type = audio[\"id\"], audio[\"mime_type\"]\n>>>                 audio_url = manish.query_media_url(audio_id)\n>>>                 audio_filename = manish.download_media(audio_url, mime_type)\n>>>                 logger.info(f\"{mobile} sent audio {audio_filename}\")\n>>>             elif message_type == \"file\":\n>>>                 file = manish.get_file(data)\n>>>                 file_id, mime_type = file[\"id\"], file[\"mime_type\"]\n>>>                 file_url = manish.query_media_url(file_id)\n>>>                 file_filename = manish.download_media(file_url, mime_type)\n>>>                 logger.info(f\"{mobile} sent file {file_filename}\")\n>>>             else:\n>>>                 logger.info(f\"{mobile} sent {message_type} \")\n>>>                 logger.info(data)\n>>>         else:\n>>>             delivery = manish.get_delivery(data)\n>>>             if delivery:\n>>>                 logger.info(f\"Message : {delivery}\")\n>>>             else:\n>>>                 logger.info(\"No new message\")\n>>>     return \"ok\"\n```\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "manish is an unofficial python wrapper for Whatsapp cloud api",
    "version": "1.3.2",
    "project_urls": {
        "Documentation": "https://github.com/t0mer/ma-nish",
        "Download": "https://pypi.org/project/ma-nish/",
        "Homepage": "https://github.com/t0mer/ma-nish",
        "Source": "https://github.com/t0mer/ma-nish"
    },
    "split_keywords": [
        "meta",
        " ma-nish",
        " facebook",
        " whatsapp"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e2f18d1da0633b97efcae1ad904aeff8148c9fce2bde878b042b5e3c9cdf30e0",
                "md5": "c4d9b6eee114561f96e4902217777ab3",
                "sha256": "597fb2b5ad20a1a8d3b7dc05de55826f886d000e35b16e6827d90bde848235b6"
            },
            "downloads": -1,
            "filename": "ma_nish-1.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c4d9b6eee114561f96e4902217777ab3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14819,
            "upload_time": "2024-12-01T09:37:38",
            "upload_time_iso_8601": "2024-12-01T09:37:38.651153Z",
            "url": "https://files.pythonhosted.org/packages/e2/f1/8d1da0633b97efcae1ad904aeff8148c9fce2bde878b042b5e3c9cdf30e0/ma_nish-1.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "984b9a55eb7882c75a51c6304ef2a204407d0a7689ec64e9bf18affdf02f6e2c",
                "md5": "881c4e038ed3a6a2d81f2cc625f89d8f",
                "sha256": "d36adca37c73a9fedc6efea50ff2f8c54ea9147976212b80d8d3f67d10cea9e5"
            },
            "downloads": -1,
            "filename": "ma_nish-1.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "881c4e038ed3a6a2d81f2cc625f89d8f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13923,
            "upload_time": "2024-12-01T09:37:43",
            "upload_time_iso_8601": "2024-12-01T09:37:43.889052Z",
            "url": "https://files.pythonhosted.org/packages/98/4b/9a55eb7882c75a51c6304ef2a204407d0a7689ec64e9bf18affdf02f6e2c/ma_nish-1.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-01 09:37:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "t0mer",
    "github_project": "ma-nish",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2024.7.4"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "2.1.1"
                ]
            ]
        },
        {
            "name": "decorator",
            "specs": [
                [
                    "==",
                    "5.1.1"
                ]
            ]
        },
        {
            "name": "geographiclib",
            "specs": [
                [
                    "==",
                    "2.0"
                ]
            ]
        },
        {
            "name": "geopy",
            "specs": [
                [
                    "==",
                    "2.3.0"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.7"
                ]
            ]
        },
        {
            "name": "pillow",
            "specs": [
                [
                    "==",
                    "10.3.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    "==",
                    "0.21.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.32.2"
                ]
            ]
        },
        {
            "name": "requests-toolbelt",
            "specs": [
                [
                    "==",
                    "0.10.1"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "1.26.19"
                ]
            ]
        },
        {
            "name": "validators",
            "specs": [
                [
                    "==",
                    "0.21.0"
                ]
            ]
        }
    ],
    "lcname": "ma-nish"
}
        
Elapsed time: 0.41561s