whatsapp-python 3.0.6__tar.gz → 3.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/.gitignore +1 -0
- whatsapp_python-3.1.0/.version +1 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/LICENSE +1 -1
- whatsapp_python-3.1.0/PKG-INFO +112 -0
- whatsapp_python-3.1.0/README.md +85 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/pyproject.toml +3 -2
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/__init__.py +56 -23
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/constants.py +1 -1
- whatsapp_python-3.0.6/.version +0 -1
- whatsapp_python-3.0.6/PKG-INFO +0 -111
- whatsapp_python-3.0.6/README.md +0 -89
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/.github/FUNDING.yml +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/.github/ISSUE_TEMPLATE/custom.md +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/.github/dependabot.yml +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/.github/workflows/codeql.yml +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/.github/workflows/dependency-review.yml +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/CONTRIBUTING.md +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/SECURITY.md +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/reply_to_message_obj.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/sending_audio.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/sending_button.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/sending_document.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/sending_image.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/sending_location.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/sending_message.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/sending_template_message.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/sending_video.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/examples/standalone_hook.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/ext/_buttons.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/ext/_media.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/ext/_message.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/ext/_property.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/ext/_send_media.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/ext/_send_others.py +0 -0
- {whatsapp_python-3.0.6 → whatsapp_python-3.1.0}/whatsapp/ext/_static.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.1.0
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: whatsapp-python
|
|
3
|
+
Version: 3.1.0
|
|
4
|
+
Summary: Open source Python wrapper for the WhatsApp Cloud API
|
|
5
|
+
Project-URL: Homepage, https://github.com/filipporomani/whatsapp
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/filipporomani/whatsapp/issues
|
|
7
|
+
Project-URL: Download, https://github.com/filipporomani/whatsapp/releases/latest
|
|
8
|
+
Author-email: Filippo Romani <mail@filipporomani.it>
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: fastapi
|
|
22
|
+
Requires-Dist: python-dotenv
|
|
23
|
+
Requires-Dist: requests
|
|
24
|
+
Requires-Dist: requests-toolbelt
|
|
25
|
+
Requires-Dist: unicorn
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
<div align="center">
|
|
29
|
+
<img src="https://gist.githubusercontent.com/boywithkeyboard/e8dc5b1810bd29e1d70346ca11d7f09d/raw/7f7eeea482f5047e62944e54182aa26c89cc299a/whatsapp_python.svg" alt="logo" width="128px">
|
|
30
|
+
<h1>whatsapp-python</h1>
|
|
31
|
+
<p>Free, open-source Python wrapper for the <a href="https://developers.facebook.com/docs/whatsapp/cloud-api">WhatsApp Cloud API</a>.<br>Forked from <a href="https://github.com/Neurotech-HQ/heyoo">Neurotech-HQ/heyoo</a>.</p>
|
|
32
|
+
<img src="https://img.shields.io/badge/made%20in-italy-008751.svg?style=flat-square" alt="Made in Italy">
|
|
33
|
+
<a href="https://pepy.tech/project/whatsapp-python"><img src="https://static.pepy.tech/personalized-badge/whatsapp-python?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads" alt="Downloads"></a>
|
|
34
|
+
<a href="https://pepy.tech/project/whatsapp-python"><img src="https://pepy.tech/badge/whatsapp-python/month" alt="Monthly Downloads"></a>
|
|
35
|
+
<a href="https://pepy.tech/project/whatsapp-python"><img src="https://pepy.tech/badge/whatsapp-python/week" alt="Weekly Downloads"></a>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
To install the library you can either use pip (latest release version):
|
|
41
|
+
|
|
42
|
+
``pip install whatsapp-python``
|
|
43
|
+
|
|
44
|
+
However I personally recomend you to install the GitHub version (always up to date)
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/filipporomani/whatsapp.git
|
|
48
|
+
cd whatsapp
|
|
49
|
+
python3 setup.py install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Documentation is available in the [wiki section](https://github.com/filipporomani/whatsapp/wiki) on GitHub.
|
|
53
|
+
|
|
54
|
+
## Why choose this library?
|
|
55
|
+
|
|
56
|
+
The main reason why I decided to fork the original library is that it uses an old version of the API and doesn't support many features.
|
|
57
|
+
|
|
58
|
+
In this library I added app events (to listen to incoming messages) and implemented an easier way to send/receive messages and media by creating the `Message`object.
|
|
59
|
+
|
|
60
|
+
I fixed some bugs and added some features, but the library still needs a lot of work to be done even if it's working and usable.
|
|
61
|
+
|
|
62
|
+
### Supported features:
|
|
63
|
+
|
|
64
|
+
- Listening to events (messages, media, etc.)
|
|
65
|
+
- Sending messages
|
|
66
|
+
- Marking messages as read
|
|
67
|
+
- Sending Media (images, audio, video and documents)
|
|
68
|
+
- Sending location
|
|
69
|
+
- Sending interactive buttons
|
|
70
|
+
- Sending template messages
|
|
71
|
+
- Parsing messages and media received
|
|
72
|
+
|
|
73
|
+
## Obtaining the WhatsApp API credentials
|
|
74
|
+
|
|
75
|
+
To use the WhatsApp API you need to create a Facebook Business account and a WhatsApp Business account.
|
|
76
|
+
|
|
77
|
+
> [!TIP]
|
|
78
|
+
> To create an account, I recommend to follow [this video](https://youtu.be/d6lNxP2gadA).
|
|
79
|
+
|
|
80
|
+
## Pricing of the API
|
|
81
|
+
|
|
82
|
+
Whereas using third-party providers of the WhatsApp API can result in monthly fees, using the WhatsApp API[^1] offered directly by Facebook is much cheaper, even if the billing documentation is quite difficult to understand.
|
|
83
|
+
|
|
84
|
+
> [!CAUTION]
|
|
85
|
+
> It is now mandatory to add a credit card to the WhatsApp account (at least for me) in order to use the service. I was even charged a fee for using a non-test phone number (~€1.20), so be careful when using the API! I'm not responsible for any costs you may face by using the API.
|
|
86
|
+
|
|
87
|
+
All the prices are available in the [**WhatsApp API docs**](https://developers.facebook.com/docs/whatsapp/pricing).
|
|
88
|
+
|
|
89
|
+
> [!TIP]
|
|
90
|
+
> One recommendation I can give you is to use a test number (you can get a free phone number and use it for testing purposes only).
|
|
91
|
+
|
|
92
|
+
## Migrating from `Neurotech-HQ/heyoo`
|
|
93
|
+
|
|
94
|
+
*You can ignore this if it's your first time using the library.*
|
|
95
|
+
|
|
96
|
+
- Any version >1.1.2 is incompatible with the original `heyoo` library! Be careful updating! Read the docs first!
|
|
97
|
+
- Any version <=1.1.2 is fully compatible with the original `heyoo` library and doesn't include breaking changes.
|
|
98
|
+
|
|
99
|
+
Switching from heyoo to whatsapp-python doesn't require any change for versions up to 1.1.2: just uninstall `heyoo`, install `whatsapp-python==1.1.2` and change the import name from `heyoo` to `whatsapp`.
|
|
100
|
+
|
|
101
|
+
For versions GREATER THAN 1.1.2, messages have became objects, so you need to change your code to use the new methods.
|
|
102
|
+
|
|
103
|
+
> [!NOTE]
|
|
104
|
+
> Documentation for version 1.1.2 can be found [here](https://github.com/filipporomani/whatsapp/wiki/v1.1.2).
|
|
105
|
+
|
|
106
|
+
## Contributing
|
|
107
|
+
|
|
108
|
+
If you are facing any issues or have any questions, please [open a new issue](https://github.com/filipporomani/whatsapp/issues/new/choose)!
|
|
109
|
+
|
|
110
|
+
*This is an open source project published under the [MIT License](LICENSE).*
|
|
111
|
+
|
|
112
|
+
[^1]: https://developers.facebook.com/docs/whatsapp/cloud-api
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://gist.githubusercontent.com/boywithkeyboard/e8dc5b1810bd29e1d70346ca11d7f09d/raw/7f7eeea482f5047e62944e54182aa26c89cc299a/whatsapp_python.svg" alt="logo" width="128px">
|
|
3
|
+
<h1>whatsapp-python</h1>
|
|
4
|
+
<p>Free, open-source Python wrapper for the <a href="https://developers.facebook.com/docs/whatsapp/cloud-api">WhatsApp Cloud API</a>.<br>Forked from <a href="https://github.com/Neurotech-HQ/heyoo">Neurotech-HQ/heyoo</a>.</p>
|
|
5
|
+
<img src="https://img.shields.io/badge/made%20in-italy-008751.svg?style=flat-square" alt="Made in Italy">
|
|
6
|
+
<a href="https://pepy.tech/project/whatsapp-python"><img src="https://static.pepy.tech/personalized-badge/whatsapp-python?period=total&units=none&left_color=grey&right_color=blue&left_text=Downloads" alt="Downloads"></a>
|
|
7
|
+
<a href="https://pepy.tech/project/whatsapp-python"><img src="https://pepy.tech/badge/whatsapp-python/month" alt="Monthly Downloads"></a>
|
|
8
|
+
<a href="https://pepy.tech/project/whatsapp-python"><img src="https://pepy.tech/badge/whatsapp-python/week" alt="Weekly Downloads"></a>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
To install the library you can either use pip (latest release version):
|
|
14
|
+
|
|
15
|
+
``pip install whatsapp-python``
|
|
16
|
+
|
|
17
|
+
However I personally recomend you to install the GitHub version (always up to date)
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
git clone https://github.com/filipporomani/whatsapp.git
|
|
21
|
+
cd whatsapp
|
|
22
|
+
python3 setup.py install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Documentation is available in the [wiki section](https://github.com/filipporomani/whatsapp/wiki) on GitHub.
|
|
26
|
+
|
|
27
|
+
## Why choose this library?
|
|
28
|
+
|
|
29
|
+
The main reason why I decided to fork the original library is that it uses an old version of the API and doesn't support many features.
|
|
30
|
+
|
|
31
|
+
In this library I added app events (to listen to incoming messages) and implemented an easier way to send/receive messages and media by creating the `Message`object.
|
|
32
|
+
|
|
33
|
+
I fixed some bugs and added some features, but the library still needs a lot of work to be done even if it's working and usable.
|
|
34
|
+
|
|
35
|
+
### Supported features:
|
|
36
|
+
|
|
37
|
+
- Listening to events (messages, media, etc.)
|
|
38
|
+
- Sending messages
|
|
39
|
+
- Marking messages as read
|
|
40
|
+
- Sending Media (images, audio, video and documents)
|
|
41
|
+
- Sending location
|
|
42
|
+
- Sending interactive buttons
|
|
43
|
+
- Sending template messages
|
|
44
|
+
- Parsing messages and media received
|
|
45
|
+
|
|
46
|
+
## Obtaining the WhatsApp API credentials
|
|
47
|
+
|
|
48
|
+
To use the WhatsApp API you need to create a Facebook Business account and a WhatsApp Business account.
|
|
49
|
+
|
|
50
|
+
> [!TIP]
|
|
51
|
+
> To create an account, I recommend to follow [this video](https://youtu.be/d6lNxP2gadA).
|
|
52
|
+
|
|
53
|
+
## Pricing of the API
|
|
54
|
+
|
|
55
|
+
Whereas using third-party providers of the WhatsApp API can result in monthly fees, using the WhatsApp API[^1] offered directly by Facebook is much cheaper, even if the billing documentation is quite difficult to understand.
|
|
56
|
+
|
|
57
|
+
> [!CAUTION]
|
|
58
|
+
> It is now mandatory to add a credit card to the WhatsApp account (at least for me) in order to use the service. I was even charged a fee for using a non-test phone number (~€1.20), so be careful when using the API! I'm not responsible for any costs you may face by using the API.
|
|
59
|
+
|
|
60
|
+
All the prices are available in the [**WhatsApp API docs**](https://developers.facebook.com/docs/whatsapp/pricing).
|
|
61
|
+
|
|
62
|
+
> [!TIP]
|
|
63
|
+
> One recommendation I can give you is to use a test number (you can get a free phone number and use it for testing purposes only).
|
|
64
|
+
|
|
65
|
+
## Migrating from `Neurotech-HQ/heyoo`
|
|
66
|
+
|
|
67
|
+
*You can ignore this if it's your first time using the library.*
|
|
68
|
+
|
|
69
|
+
- Any version >1.1.2 is incompatible with the original `heyoo` library! Be careful updating! Read the docs first!
|
|
70
|
+
- Any version <=1.1.2 is fully compatible with the original `heyoo` library and doesn't include breaking changes.
|
|
71
|
+
|
|
72
|
+
Switching from heyoo to whatsapp-python doesn't require any change for versions up to 1.1.2: just uninstall `heyoo`, install `whatsapp-python==1.1.2` and change the import name from `heyoo` to `whatsapp`.
|
|
73
|
+
|
|
74
|
+
For versions GREATER THAN 1.1.2, messages have became objects, so you need to change your code to use the new methods.
|
|
75
|
+
|
|
76
|
+
> [!NOTE]
|
|
77
|
+
> Documentation for version 1.1.2 can be found [here](https://github.com/filipporomani/whatsapp/wiki/v1.1.2).
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
|
|
81
|
+
If you are facing any issues or have any questions, please [open a new issue](https://github.com/filipporomani/whatsapp/issues/new/choose)!
|
|
82
|
+
|
|
83
|
+
*This is an open source project published under the [MIT License](LICENSE).*
|
|
84
|
+
|
|
85
|
+
[^1]: https://developers.facebook.com/docs/whatsapp/cloud-api
|
|
@@ -4,11 +4,11 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name="whatsapp-python"
|
|
7
|
-
version="3.0
|
|
7
|
+
version="3.1.0"
|
|
8
8
|
authors = [{name="Filippo Romani", email="mail@filipporomani.it"}]
|
|
9
9
|
description="Open source Python wrapper for the WhatsApp Cloud API"
|
|
10
10
|
readme = "README.md"
|
|
11
|
-
requires-python = ">=3.
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
12
|
classifiers=[
|
|
13
13
|
"Development Status :: 4 - Beta",
|
|
14
14
|
"Intended Audience :: Developers",
|
|
@@ -21,6 +21,7 @@ classifiers=[
|
|
|
21
21
|
"Programming Language :: Python :: 3.10",
|
|
22
22
|
"Programming Language :: Python :: 3.11",
|
|
23
23
|
]
|
|
24
|
+
dependencies = ["fastapi", "unicorn","requests_toolbelt", "requests", "python-dotenv"]
|
|
24
25
|
|
|
25
26
|
[project.urls]
|
|
26
27
|
"Homepage" = "https://github.com/filipporomani/whatsapp"
|
|
@@ -5,7 +5,7 @@ from __future__ import annotations
|
|
|
5
5
|
|
|
6
6
|
import requests
|
|
7
7
|
import logging
|
|
8
|
-
from fastapi import FastAPI, Request
|
|
8
|
+
from fastapi import FastAPI, HTTPException, Request
|
|
9
9
|
from uvicorn import run as _run
|
|
10
10
|
from .constants import VERSION
|
|
11
11
|
from . import ext
|
|
@@ -16,10 +16,10 @@ from .ext._send_media import send_image, send_video, send_audio, send_location,
|
|
|
16
16
|
from .ext._media import upload_media, query_media_url, download_media, delete_media
|
|
17
17
|
from .ext._buttons import send_button, create_button, send_reply_button
|
|
18
18
|
from .ext._static import is_message, get_mobile, get_author, get_name, get_message, get_message_id, get_message_type, get_message_timestamp, get_audio, get_delivery, get_document, get_image, get_interactive_response, get_location, get_video, changed_field
|
|
19
|
-
|
|
19
|
+
import json
|
|
20
20
|
|
|
21
21
|
class WhatsApp(object):
|
|
22
|
-
def __init__(self, token: str = "", phone_number_id: str = "", logger: bool = True, update_check: bool = True):
|
|
22
|
+
def __init__(self, token: str = "", phone_number_id: str = "", logger: bool = True, update_check: bool = True, verify_token: str = ""):
|
|
23
23
|
"""
|
|
24
24
|
Initialize the WhatsApp Object
|
|
25
25
|
|
|
@@ -71,8 +71,10 @@ class WhatsApp(object):
|
|
|
71
71
|
self.phone_number_id = phone_number_id
|
|
72
72
|
self.base_url = "https://graph.facebook.com/v18.0"
|
|
73
73
|
self.url = f"{self.base_url}/{phone_number_id}/messages"
|
|
74
|
+
self.verify_token = verify_token
|
|
75
|
+
|
|
74
76
|
|
|
75
|
-
async def base():
|
|
77
|
+
async def base(*args):
|
|
76
78
|
pass
|
|
77
79
|
self.message_handler = base
|
|
78
80
|
self.other_handler = base
|
|
@@ -91,12 +93,12 @@ class WhatsApp(object):
|
|
|
91
93
|
|
|
92
94
|
@self.app.get("/")
|
|
93
95
|
async def verify_endpoint(r: Request):
|
|
94
|
-
if r.query_params.get("hub.verify_token") == self.
|
|
96
|
+
if r.query_params.get("hub.verify_token") == self.verify_token:
|
|
95
97
|
logging.info("Verified webhook")
|
|
96
98
|
challenge = r.query_params.get("hub.challenge")
|
|
97
99
|
self.verification_handler(challenge)
|
|
98
100
|
self.other_handler(challenge)
|
|
99
|
-
return
|
|
101
|
+
return int(challenge)
|
|
100
102
|
logging.error("Webhook Verification failed")
|
|
101
103
|
await self.verification_handler(False)
|
|
102
104
|
await self.other_handler(False)
|
|
@@ -104,19 +106,32 @@ class WhatsApp(object):
|
|
|
104
106
|
|
|
105
107
|
@self.app.post("/")
|
|
106
108
|
async def hook(r: Request):
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
109
|
+
try:
|
|
110
|
+
# Handle Webhook Subscriptions
|
|
111
|
+
data = await r.json()
|
|
112
|
+
if data is None:
|
|
113
|
+
return {"success": False}
|
|
114
|
+
logging.info("Received webhook data: %s", data)
|
|
115
|
+
data_str = json.dumps(data, indent=4)
|
|
116
|
+
logging.debug(f"Received webhook data: {data_str}")
|
|
117
|
+
|
|
118
|
+
changed_field = self.changed_field(data)
|
|
119
|
+
if changed_field == "messages":
|
|
120
|
+
new_message = self.is_message(data)
|
|
121
|
+
if new_message:
|
|
122
|
+
msg = Message(instance=self, data=data)
|
|
123
|
+
await self.message_handler(msg)
|
|
124
|
+
await self.other_handler(msg)
|
|
125
|
+
return {"success": True}
|
|
126
|
+
except Exception as e:
|
|
127
|
+
logging.error(f"Error parsing message: {e}")
|
|
128
|
+
raise HTTPException(status_code=500, detail={
|
|
129
|
+
"success": False,
|
|
130
|
+
"error": str(e)
|
|
131
|
+
})
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
120
135
|
|
|
121
136
|
# all the files starting with _ are imported here, and should not be imported directly.
|
|
122
137
|
|
|
@@ -137,6 +152,23 @@ class WhatsApp(object):
|
|
|
137
152
|
changed_field = staticmethod(changed_field)
|
|
138
153
|
get_author = staticmethod(get_author)
|
|
139
154
|
|
|
155
|
+
send_button = send_button
|
|
156
|
+
create_button = create_button
|
|
157
|
+
send_reply_button = send_reply_button
|
|
158
|
+
send_image = send_image
|
|
159
|
+
send_video = send_video
|
|
160
|
+
send_audio = send_audio
|
|
161
|
+
send_location = send_location
|
|
162
|
+
send_sticker = send_sticker
|
|
163
|
+
send_document = send_document
|
|
164
|
+
upload_media = upload_media
|
|
165
|
+
query_media_url = query_media_url
|
|
166
|
+
download_media = download_media
|
|
167
|
+
delete_media = delete_media
|
|
168
|
+
send_template = send_template
|
|
169
|
+
send_custom_json = send_custom_json
|
|
170
|
+
send_contacts = send_contacts
|
|
171
|
+
|
|
140
172
|
authorized = property(authorized)
|
|
141
173
|
|
|
142
174
|
def create_message(self, **kwargs) -> Message:
|
|
@@ -184,6 +216,10 @@ class WhatsApp(object):
|
|
|
184
216
|
|
|
185
217
|
class Message(object):
|
|
186
218
|
def __init__(self, id: int = None, data: dict = {}, instance: WhatsApp = None, content: str = "", to: str = "", rec_type: str = "individual"): # type: ignore
|
|
219
|
+
self.instance = instance
|
|
220
|
+
self.url = self.instance.url
|
|
221
|
+
self.headers = self.instance.headers
|
|
222
|
+
|
|
187
223
|
try:
|
|
188
224
|
self.id = instance.get_message_id(data)
|
|
189
225
|
except:
|
|
@@ -239,9 +275,6 @@ class Message(object):
|
|
|
239
275
|
self.interactive = self.instance.get_interactive_response(data)
|
|
240
276
|
except:
|
|
241
277
|
pass
|
|
242
|
-
|
|
243
|
-
self.instance = instance
|
|
244
|
-
self.url = self.instance.url
|
|
245
|
-
self.headers = self.instance.headers
|
|
278
|
+
|
|
246
279
|
|
|
247
280
|
from .ext._message import send, reply, mark_as_read
|
whatsapp_python-3.0.6/.version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
3.0.6
|
whatsapp_python-3.0.6/PKG-INFO
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: whatsapp-python
|
|
3
|
-
Version: 3.0.6
|
|
4
|
-
Summary: Open source Python wrapper for the WhatsApp Cloud API
|
|
5
|
-
Project-URL: Homepage, https://github.com/filipporomani/whatsapp
|
|
6
|
-
Project-URL: Bug Tracker, https://github.com/filipporomani/whatsapp/issues
|
|
7
|
-
Project-URL: Download, https://github.com/filipporomani/whatsapp/releases/latest
|
|
8
|
-
Author-email: Filippo Romani <mail@filipporomani.it>
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Classifier: Development Status :: 4 - Beta
|
|
11
|
-
Classifier: Intended Audience :: Developers
|
|
12
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
-
Classifier: Topic :: Software Development :: Build Tools
|
|
20
|
-
Requires-Python: >=3.8
|
|
21
|
-
Description-Content-Type: text/markdown
|
|
22
|
-
|
|
23
|
-
# [whatsapp-python](https://pypi.org/project/whatsapp-python/)
|
|
24
|
-
|
|
25
|
-

|
|
26
|
-
[](https://pepy.tech/project/whatsapp-python)
|
|
27
|
-
[](https://pepy.tech/project/whatsapp-python)
|
|
28
|
-
[](https://pepy.tech/project/whatsapp-python)
|
|
29
|
-
|
|
30
|
-
Free, open-source Python wrapper for the [WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api).
|
|
31
|
-
|
|
32
|
-
Forked from [Neurotech-HQ/heyoo](https://github.com/Neurotech-HQ/heyoo)
|
|
33
|
-
|
|
34
|
-
## Supported features
|
|
35
|
-
|
|
36
|
-
1. Listening to events (messages, media, etc.)
|
|
37
|
-
2. Sending messages
|
|
38
|
-
3. Marking messages as read
|
|
39
|
-
4. Sending Media (images, audio, video and documents)
|
|
40
|
-
5. Sending location
|
|
41
|
-
6. Sending interactive buttons
|
|
42
|
-
7. Sending template messages
|
|
43
|
-
8. Parsing messages and media received
|
|
44
|
-
|
|
45
|
-
## Docs
|
|
46
|
-
|
|
47
|
-
Docs are available in the [**wiki**](https://github.com/filipporomani/whatsapp/wiki) section on GitHub.
|
|
48
|
-
|
|
49
|
-
## Why choose this library?
|
|
50
|
-
|
|
51
|
-
The main reason why I decided to fork the original library is that it uses an old version of the API and doesn't support many features.
|
|
52
|
-
|
|
53
|
-
In this library I added app events (to listen to incoming messages) and implemented an easier way to send/receive messages and media by creating the `Message`object.
|
|
54
|
-
|
|
55
|
-
I fixed some bugs and added some features, but the library still needs a lot of work to be done even if it's working and usable.
|
|
56
|
-
|
|
57
|
-
## Installation
|
|
58
|
-
|
|
59
|
-
To install the library you can either use pip (latest release version):
|
|
60
|
-
|
|
61
|
-
``pip install whatsapp-python``
|
|
62
|
-
|
|
63
|
-
or git (latest development version):
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
git clone https://github.com/filipporomani/whatsapp.git
|
|
67
|
-
cd whatsapp
|
|
68
|
-
python3 setup.py install
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Obtaining the WhatsApp API credentials
|
|
72
|
-
|
|
73
|
-
To use the WhatsApp API you need to create a Facebook Business account and a WhatsApp Business account.
|
|
74
|
-
|
|
75
|
-
**To create an account, I recomend to follow [this video](https://youtu.be/d6lNxP2gadA?si=_hbis7aP7MoKkck0)**
|
|
76
|
-
|
|
77
|
-
## Costs of the API
|
|
78
|
-
|
|
79
|
-
While using third-party API providers of the WhatsApp API may have some monthly fees, using the WhatsApp API provided directly by Facebook is way cheaper, even if the billing docs are pretty hard to understand.
|
|
80
|
-
The first 1000 chats created are free, then there is a pay-as-you-go fee that is paid for each conversation started.
|
|
81
|
-
|
|
82
|
-
**IMPORTANT**: it is now mandatory (at least it was for me) to add a credit card to the whatsapp account to use the service. I eventually got billed for using a non-test number (~1,20€), so be carefull using the API! I'm not responsible for any costs you may have using the API.
|
|
83
|
-
|
|
84
|
-
A suggestion I can give you is to use a test number (you can get one for free and use it for testing purposes only).
|
|
85
|
-
|
|
86
|
-
All the prices are available in the [**WhatsApp API docs**](https://developers.facebook.com/docs/whatsapp/pricing)
|
|
87
|
-
|
|
88
|
-
## Switching from `Neurotech-HQ/heyoo`
|
|
89
|
-
*You can ignore this if it's your first time using the library.*
|
|
90
|
-
Any version >1.1.2 is incompatible with the original `heyoo` library! Be careful updating! Read the docs first!
|
|
91
|
-
Any version <=1.1.2 is fully compatible with the original `heyoo` library and doesn't include any breaking change..
|
|
92
|
-
|
|
93
|
-
Switching from heyoo to whatsapp-python doesn't require any change for versions up to 1.1.2: just uninstall `heyoo`, install `whatsapp-python==1.1.2` and change the import name from `heyoo` to `whatsapp`.
|
|
94
|
-
For version which are GREATER THEN 1.1.2, messages have became objects, so you need to change your code to use the new methods.
|
|
95
|
-
|
|
96
|
-
**Note**: docs for version 1.1.2 are available in the [**dedicated wiki page**](https://github.com/filipporomani/whatsapp/wiki/v1.1.2).
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
## Issues
|
|
102
|
-
|
|
103
|
-
If you are facing any issues or have any questions, please open an issue on the [**GitHub repository**](https://github.com/filipporomani/whatsapp/issues)
|
|
104
|
-
|
|
105
|
-
## Contributing
|
|
106
|
-
|
|
107
|
-
This is an opensource project published under the ```MIT License```: [**LICENSE**](LICENSE).
|
|
108
|
-
|
|
109
|
-
## References
|
|
110
|
-
|
|
111
|
-
1. [WhatsApp Cloud API official documentation](https://developers.facebook.com/docs/whatsapp/cloud-api/)
|
whatsapp_python-3.0.6/README.md
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
# [whatsapp-python](https://pypi.org/project/whatsapp-python/)
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-
[](https://pepy.tech/project/whatsapp-python)
|
|
5
|
-
[](https://pepy.tech/project/whatsapp-python)
|
|
6
|
-
[](https://pepy.tech/project/whatsapp-python)
|
|
7
|
-
|
|
8
|
-
Free, open-source Python wrapper for the [WhatsApp Cloud API](https://developers.facebook.com/docs/whatsapp/cloud-api).
|
|
9
|
-
|
|
10
|
-
Forked from [Neurotech-HQ/heyoo](https://github.com/Neurotech-HQ/heyoo)
|
|
11
|
-
|
|
12
|
-
## Supported features
|
|
13
|
-
|
|
14
|
-
1. Listening to events (messages, media, etc.)
|
|
15
|
-
2. Sending messages
|
|
16
|
-
3. Marking messages as read
|
|
17
|
-
4. Sending Media (images, audio, video and documents)
|
|
18
|
-
5. Sending location
|
|
19
|
-
6. Sending interactive buttons
|
|
20
|
-
7. Sending template messages
|
|
21
|
-
8. Parsing messages and media received
|
|
22
|
-
|
|
23
|
-
## Docs
|
|
24
|
-
|
|
25
|
-
Docs are available in the [**wiki**](https://github.com/filipporomani/whatsapp/wiki) section on GitHub.
|
|
26
|
-
|
|
27
|
-
## Why choose this library?
|
|
28
|
-
|
|
29
|
-
The main reason why I decided to fork the original library is that it uses an old version of the API and doesn't support many features.
|
|
30
|
-
|
|
31
|
-
In this library I added app events (to listen to incoming messages) and implemented an easier way to send/receive messages and media by creating the `Message`object.
|
|
32
|
-
|
|
33
|
-
I fixed some bugs and added some features, but the library still needs a lot of work to be done even if it's working and usable.
|
|
34
|
-
|
|
35
|
-
## Installation
|
|
36
|
-
|
|
37
|
-
To install the library you can either use pip (latest release version):
|
|
38
|
-
|
|
39
|
-
``pip install whatsapp-python``
|
|
40
|
-
|
|
41
|
-
or git (latest development version):
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
git clone https://github.com/filipporomani/whatsapp.git
|
|
45
|
-
cd whatsapp
|
|
46
|
-
python3 setup.py install
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Obtaining the WhatsApp API credentials
|
|
50
|
-
|
|
51
|
-
To use the WhatsApp API you need to create a Facebook Business account and a WhatsApp Business account.
|
|
52
|
-
|
|
53
|
-
**To create an account, I recomend to follow [this video](https://youtu.be/d6lNxP2gadA?si=_hbis7aP7MoKkck0)**
|
|
54
|
-
|
|
55
|
-
## Costs of the API
|
|
56
|
-
|
|
57
|
-
While using third-party API providers of the WhatsApp API may have some monthly fees, using the WhatsApp API provided directly by Facebook is way cheaper, even if the billing docs are pretty hard to understand.
|
|
58
|
-
The first 1000 chats created are free, then there is a pay-as-you-go fee that is paid for each conversation started.
|
|
59
|
-
|
|
60
|
-
**IMPORTANT**: it is now mandatory (at least it was for me) to add a credit card to the whatsapp account to use the service. I eventually got billed for using a non-test number (~1,20€), so be carefull using the API! I'm not responsible for any costs you may have using the API.
|
|
61
|
-
|
|
62
|
-
A suggestion I can give you is to use a test number (you can get one for free and use it for testing purposes only).
|
|
63
|
-
|
|
64
|
-
All the prices are available in the [**WhatsApp API docs**](https://developers.facebook.com/docs/whatsapp/pricing)
|
|
65
|
-
|
|
66
|
-
## Switching from `Neurotech-HQ/heyoo`
|
|
67
|
-
*You can ignore this if it's your first time using the library.*
|
|
68
|
-
Any version >1.1.2 is incompatible with the original `heyoo` library! Be careful updating! Read the docs first!
|
|
69
|
-
Any version <=1.1.2 is fully compatible with the original `heyoo` library and doesn't include any breaking change..
|
|
70
|
-
|
|
71
|
-
Switching from heyoo to whatsapp-python doesn't require any change for versions up to 1.1.2: just uninstall `heyoo`, install `whatsapp-python==1.1.2` and change the import name from `heyoo` to `whatsapp`.
|
|
72
|
-
For version which are GREATER THEN 1.1.2, messages have became objects, so you need to change your code to use the new methods.
|
|
73
|
-
|
|
74
|
-
**Note**: docs for version 1.1.2 are available in the [**dedicated wiki page**](https://github.com/filipporomani/whatsapp/wiki/v1.1.2).
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
## Issues
|
|
80
|
-
|
|
81
|
-
If you are facing any issues or have any questions, please open an issue on the [**GitHub repository**](https://github.com/filipporomani/whatsapp/issues)
|
|
82
|
-
|
|
83
|
-
## Contributing
|
|
84
|
-
|
|
85
|
-
This is an opensource project published under the ```MIT License```: [**LICENSE**](LICENSE).
|
|
86
|
-
|
|
87
|
-
## References
|
|
88
|
-
|
|
89
|
-
1. [WhatsApp Cloud API official documentation](https://developers.facebook.com/docs/whatsapp/cloud-api/)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|