whatsapp-python 4.0.2__tar.gz → 4.2.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.
Files changed (45) hide show
  1. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/PKG-INFO +5 -3
  2. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/README.md +4 -1
  3. whatsapp_python-4.2.0/async_test.py +142 -0
  4. whatsapp_python-4.2.0/tests.py +128 -0
  5. whatsapp_python-4.2.0/whatsapp/__init__.py +813 -0
  6. whatsapp_python-4.2.0/whatsapp/async_ext/_buttons.py +118 -0
  7. whatsapp_python-4.2.0/whatsapp/async_ext/_media.py +169 -0
  8. whatsapp_python-4.2.0/whatsapp/async_ext/_message.py +164 -0
  9. whatsapp_python-4.2.0/whatsapp/async_ext/_send_media.py +377 -0
  10. whatsapp_python-4.2.0/whatsapp/async_ext/_send_others.py +120 -0
  11. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/whatsapp/constants.py +1 -1
  12. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/whatsapp/ext/_buttons.py +2 -0
  13. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/whatsapp/ext/_media.py +5 -6
  14. whatsapp_python-4.2.0/whatsapp/ext/_property.py +5 -0
  15. whatsapp_python-4.2.0/whatsapp/ext/_static.py +329 -0
  16. whatsapp_python-4.0.2/whatsapp/__init__.py +0 -399
  17. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.github/FUNDING.yml +0 -0
  18. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  19. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.github/ISSUE_TEMPLATE/custom.md +0 -0
  20. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  21. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.github/dependabot.yml +0 -0
  22. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.github/workflows/codeql.yml +0 -0
  23. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.github/workflows/dependency-review.yml +0 -0
  24. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.github/workflows/python-publish.yml +0 -0
  25. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/.gitignore +0 -0
  26. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/CODE_OF_CONDUCT.md +0 -0
  27. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/CONTRIBUTING.md +0 -0
  28. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/LICENSE +0 -0
  29. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/SECURITY.md +0 -0
  30. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/reply_to_message_obj.py +0 -0
  31. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/sending_audio.py +0 -0
  32. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/sending_button.py +0 -0
  33. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/sending_document.py +0 -0
  34. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/sending_image.py +0 -0
  35. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/sending_location.py +0 -0
  36. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/sending_message.py +0 -0
  37. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/sending_template_message.py +0 -0
  38. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/sending_video.py +0 -0
  39. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/examples/standalone_hook.py +0 -0
  40. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/pyproject.toml +0 -0
  41. {whatsapp_python-4.0.2/whatsapp/ext → whatsapp_python-4.2.0/whatsapp/async_ext}/_property.py +0 -0
  42. {whatsapp_python-4.0.2/whatsapp/ext → whatsapp_python-4.2.0/whatsapp/async_ext}/_static.py +0 -0
  43. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/whatsapp/ext/_message.py +0 -0
  44. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/whatsapp/ext/_send_media.py +0 -0
  45. {whatsapp_python-4.0.2 → whatsapp_python-4.2.0}/whatsapp/ext/_send_others.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: whatsapp-python
3
- Version: 4.0.2
3
+ Version: 4.2.0
4
4
  Summary: Open source Python wrapper for the WhatsApp Cloud API
5
5
  Project-URL: Homepage, https://github.com/filipporomani/whatsapp-python
6
6
  Project-URL: Docs, https://github.com/filipporomani/whatsapp-python/wiki
@@ -8,7 +8,6 @@ Project-URL: Issues Reporting, https://github.com/filipporomani/whatsapp-python/
8
8
  Project-URL: Download, https://github.com/filipporomani/whatsapp-python/releases/latest
9
9
  Project-URL: Changelog, https://github.com/filipporomani/whatsapp-python/releases
10
10
  Author-email: Filippo Romani <mail@filipporomani.it>
11
- License-File: LICENSE
12
11
  Classifier: Development Status :: 4 - Beta
13
12
  Classifier: Intended Audience :: Customer Service
14
13
  Classifier: Intended Audience :: Developers
@@ -72,16 +71,19 @@ Documentation is available in the [wiki](https://github.com/filipporomani/whatsa
72
71
 
73
72
  ## Why choose this library?
74
73
 
75
- The main reason why I decided to fork the original library is that it uses an old version of the API, it's missing many and it's not mantained anymore.
74
+ The main reason why I decided to fork the original `heyoo` library is that it uses an old version of the API, it's missing many and it's not mantained anymore.
76
75
 
77
76
  In this fork I added app events (to listen to incoming messages) and implemented an easier way to send/receive messages and media by using the `Message` object.
78
77
  The API version is always up to date and I'm always adding new features and fixing bugs.
79
78
 
79
+ I also added a full asyncronous version of the library, which is faster and more efficient than the syncronous one.
80
+
80
81
  I fixed some bugs and added many features, however the library can still be improved.
81
82
 
82
83
  ### Supported features:
83
84
 
84
85
  - Listening to events (messages, media, etc.)
86
+ - Async version available
85
87
  - Sending messages
86
88
  - Sending messages from different numbers individually
87
89
  - Marking messages as read
@@ -35,16 +35,19 @@ Documentation is available in the [wiki](https://github.com/filipporomani/whatsa
35
35
 
36
36
  ## Why choose this library?
37
37
 
38
- The main reason why I decided to fork the original library is that it uses an old version of the API, it's missing many and it's not mantained anymore.
38
+ The main reason why I decided to fork the original `heyoo` library is that it uses an old version of the API, it's missing many and it's not mantained anymore.
39
39
 
40
40
  In this fork I added app events (to listen to incoming messages) and implemented an easier way to send/receive messages and media by using the `Message` object.
41
41
  The API version is always up to date and I'm always adding new features and fixing bugs.
42
42
 
43
+ I also added a full asyncronous version of the library, which is faster and more efficient than the syncronous one.
44
+
43
45
  I fixed some bugs and added many features, however the library can still be improved.
44
46
 
45
47
  ### Supported features:
46
48
 
47
49
  - Listening to events (messages, media, etc.)
50
+ - Async version available
48
51
  - Sending messages
49
52
  - Sending messages from different numbers individually
50
53
  - Marking messages as read
@@ -0,0 +1,142 @@
1
+ from whatsapp import WhatsApp, Message, AsyncWhatsApp
2
+ from dotenv import load_dotenv
3
+ from os import getenv
4
+ import asyncio
5
+
6
+ load_dotenv()
7
+ token = getenv("GRAPH_API_TOKEN")
8
+ phone_number_id = {1: getenv("TEST_PHONE_NUMBER_ID")}
9
+ dest_phone_number = getenv("DEST_PHONE_NUMBER")
10
+
11
+ app = AsyncWhatsApp(token=token, phone_number_id=phone_number_id,
12
+ update_check=False)
13
+ loop = asyncio.get_event_loop()
14
+ msg = app.create_message(to=dest_phone_number, content="Hello world")
15
+
16
+ async def run_test():
17
+
18
+ # test every single method and print the result
19
+ print("Testing send_text")
20
+ v = await msg.send()
21
+ # print(v)
22
+ # await asyncio.sleep(1)
23
+ # print("Getting request status")
24
+ # print(v.result())
25
+
26
+
27
+ print("Testing send_reply_button")
28
+ v = await app.send_reply_button(
29
+ button={
30
+ "type": "button",
31
+ "body": {
32
+ "text": "This is a test button"
33
+ },
34
+ "action": {
35
+ "buttons": [
36
+ {
37
+ "type": "reply",
38
+ "reply": {
39
+ "id": "b1",
40
+ "title": "This is button 1"
41
+ }
42
+ },
43
+ {
44
+ "type": "reply",
45
+ "reply": {
46
+ "id": "b2",
47
+ "title": "this is button 2"
48
+ }
49
+ }
50
+ ]
51
+ }
52
+ },
53
+ recipient_id=dest_phone_number,
54
+ sender=1
55
+
56
+ )
57
+ print(f"send_reply_button: {v}")
58
+
59
+
60
+ print("Creating button")
61
+ v = app.create_button(
62
+ button={
63
+ "header": {
64
+ "type": "text",
65
+ "text": "your-header-content"
66
+ },
67
+ "body": {
68
+ "text": "your-text-message-content"
69
+ },
70
+ "footer": {
71
+ "text": "your-footer-content"
72
+ },
73
+ "action": {
74
+ "button": "cta-button-content",
75
+ "sections": [
76
+ {
77
+ "title": "your-section-title-content",
78
+ "rows": [
79
+ {
80
+ "id": "unique-row-identifier",
81
+ "title": "row-title-content",
82
+ "description": "row-description-content",
83
+ }
84
+ ]
85
+ },
86
+ ]
87
+ }
88
+ },
89
+ )
90
+ print(f"create_button: {v}")
91
+ print("sending button")
92
+ v = await app.send_button({
93
+ "header": "Header Testing",
94
+ "body": "Body Testing",
95
+ "footer": "Footer Testing",
96
+ "action": {
97
+ "button": "cta-button-content",
98
+ "sections": [
99
+ {
100
+ "title": "your-secti",
101
+ "rows": [
102
+ {
103
+ "id": "unique-row-",
104
+ "title": "row-title-",
105
+ "description": "row-description-",
106
+ }
107
+ ]
108
+ },
109
+ ]
110
+ }
111
+ }, dest_phone_number, sender=1)
112
+ print(f"send_button: {v}")
113
+ print("sending image")
114
+ v = await app.send_image(
115
+ "https://file-examples.com/storage/feb05093336710053a32bc1/2017/10/file_example_JPG_1MB.jpg", dest_phone_number, sender=1)
116
+ print(f"send_image: {v}")
117
+ print("sending video")
118
+ v = await app.send_video(
119
+ "https://file-examples.com/storage/feb05093336710053a32bc1/2017/04/file_example_MP4_480_1_5MG.mp4", dest_phone_number, sender=1)
120
+ print(f"send_video: {v}")
121
+ print("sending audio")
122
+ v = await app.send_audio(
123
+ "https://file-examples.com/storage/feb05093336710053a32bc1/2017/11/file_example_MP3_1MG.mp3", dest_phone_number, sender=1)
124
+ print(f"send_audio: {v}")
125
+ print("sending document")
126
+ v = await app.send_document(
127
+ "https://file-examples.com/storage/feb05093336710053a32bc1/2017/10/file-example_PDF_1MB.pdf", dest_phone_number, sender=1)
128
+ print(f"send_document: {v}")
129
+ print("sending location")
130
+ v = await app.send_location("37.7749", "-122.4194", "test",
131
+ "test, test", dest_phone_number, sender=1)
132
+ print(f"send_location: {v}")
133
+ print("sending template")
134
+ v = await app.send_template(
135
+ "hello_world", dest_phone_number, sender=1)
136
+ print(f"send_template: {v}") # this returns error if the phone number is not a test phone number
137
+
138
+ await asyncio.sleep(10)
139
+
140
+
141
+
142
+ asyncio.run(run_test())
@@ -0,0 +1,128 @@
1
+ from whatsapp import WhatsApp, Message
2
+ from dotenv import load_dotenv
3
+ from os import getenv
4
+
5
+ load_dotenv()
6
+ token = getenv("GRAPH_API_TOKEN")
7
+ phone_number_id = {1: getenv("TEST_PHONE_NUMBER_ID")}
8
+ dest_phone_number = getenv("DEST_PHONE_NUMBER")
9
+
10
+ app = WhatsApp(token=token, phone_number_id=phone_number_id,
11
+ update_check=False)
12
+ msg = app.create_message(to=dest_phone_number, content="Hello world")
13
+
14
+
15
+ # test every single method and print the result
16
+ print("Testing send_text")
17
+ msg.send(sender=1)
18
+
19
+ print("Testing send_reply_button")
20
+ v = app.send_reply_button(
21
+ button={
22
+ "type": "button",
23
+ "body": {
24
+ "text": "This is a test button"
25
+ },
26
+ "action": {
27
+ "buttons": [
28
+ {
29
+ "type": "reply",
30
+ "reply": {
31
+ "id": "b1",
32
+ "title": "This is button 1"
33
+ }
34
+ },
35
+ {
36
+ "type": "reply",
37
+ "reply": {
38
+ "id": "b2",
39
+ "title": "this is button 2"
40
+ }
41
+ }
42
+ ]
43
+ }
44
+ },
45
+ recipient_id=dest_phone_number,
46
+ sender=1
47
+
48
+ )
49
+ print(f"send_reply_button: {v}")
50
+
51
+
52
+ print("Creating button")
53
+ v = app.create_button(
54
+ button={
55
+ "header": {
56
+ "type": "text",
57
+ "text": "your-header-content"
58
+ },
59
+ "body": {
60
+ "text": "your-text-message-content"
61
+ },
62
+ "footer": {
63
+ "text": "your-footer-content"
64
+ },
65
+ "action": {
66
+ "button": "cta-button-content",
67
+ "sections": [
68
+ {
69
+ "title": "your-section-title-content",
70
+ "rows": [
71
+ {
72
+ "id": "unique-row-identifier",
73
+ "title": "row-title-content",
74
+ "description": "row-description-content",
75
+ }
76
+ ]
77
+ },
78
+ ]
79
+ }
80
+ },
81
+ )
82
+ print(f"create_button: {v}")
83
+ print("sending button")
84
+ v = app.send_button({
85
+ "header": "Header Testing",
86
+ "body": "Body Testing",
87
+ "footer": "Footer Testing",
88
+ "action": {
89
+ "button": "cta-button-content",
90
+ "sections": [
91
+ {
92
+ "title": "your-secti",
93
+ "rows": [
94
+ {
95
+ "id": "unique-row-",
96
+ "title": "row-title-",
97
+ "description": "row-description-",
98
+ }
99
+ ]
100
+ },
101
+ ]
102
+ }
103
+ }, dest_phone_number, sender=1)
104
+ print(f"send_button: {v}")
105
+ print("sending image")
106
+ v = app.send_image(
107
+ "https://file-examples.com/storage/feb05093336710053a32bc1/2017/10/file_example_JPG_1MB.jpg", dest_phone_number, sender=1)
108
+ print(f"send_image: {v}")
109
+ print("sending video")
110
+ v = app.send_video(
111
+ "https://file-examples.com/storage/feb05093336710053a32bc1/2017/04/file_example_MP4_480_1_5MG.mp4", dest_phone_number, sender=1)
112
+ print(f"send_video: {v}")
113
+ print("sending audio")
114
+ v = app.send_audio(
115
+ "https://file-examples.com/storage/feb05093336710053a32bc1/2017/11/file_example_MP3_1MG.mp3", dest_phone_number, sender=1)
116
+ print(f"send_audio: {v}")
117
+ print("sending document")
118
+ v = app.send_document(
119
+ "https://file-examples.com/storage/feb05093336710053a32bc1/2017/10/file-example_PDF_1MB.pdf", dest_phone_number, sender=1)
120
+ print(f"send_document: {v}")
121
+ print("sending location")
122
+ v = app.send_location("37.7749", "-122.4194", "test",
123
+ "test, test", dest_phone_number, sender=1)
124
+ print(f"send_location: {v}")
125
+ print("sending template")
126
+ v = app.send_template(
127
+ "hello_world", dest_phone_number, sender=1)
128
+ print(f"send_template: {v}") # this returns error if the phone number is not a test phone number