whatsapp-python 3.0.4__tar.gz → 3.0.6__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 (37) hide show
  1. whatsapp_python-3.0.6/.version +1 -0
  2. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/PKG-INFO +1 -1
  3. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/SECURITY.md +2 -1
  4. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/pyproject.toml +5 -2
  5. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/whatsapp/__init__.py +21 -12
  6. whatsapp_python-3.0.6/whatsapp/constants.py +3 -0
  7. whatsapp_python-3.0.4/.version +0 -1
  8. whatsapp_python-3.0.4/examples/example_hook_obj.py +0 -85
  9. whatsapp_python-3.0.4/whatsapp/constants.py +0 -3
  10. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/.github/FUNDING.yml +0 -0
  11. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  12. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/.github/ISSUE_TEMPLATE/custom.md +0 -0
  13. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  14. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/.github/dependabot.yml +0 -0
  15. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/.github/workflows/codeql.yml +0 -0
  16. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/.github/workflows/dependency-review.yml +0 -0
  17. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/.gitignore +0 -0
  18. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/CONTRIBUTING.md +0 -0
  19. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/LICENSE +0 -0
  20. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/README.md +0 -0
  21. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/reply_to_message_obj.py +0 -0
  22. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/sending_audio.py +0 -0
  23. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/sending_button.py +0 -0
  24. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/sending_document.py +0 -0
  25. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/sending_image.py +0 -0
  26. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/sending_location.py +0 -0
  27. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/sending_message.py +0 -0
  28. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/sending_template_message.py +0 -0
  29. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/sending_video.py +0 -0
  30. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/examples/standalone_hook.py +0 -0
  31. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/whatsapp/ext/_buttons.py +0 -0
  32. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/whatsapp/ext/_media.py +0 -0
  33. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/whatsapp/ext/_message.py +0 -0
  34. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/whatsapp/ext/_property.py +0 -0
  35. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/whatsapp/ext/_send_media.py +0 -0
  36. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/whatsapp/ext/_send_others.py +0 -0
  37. {whatsapp_python-3.0.4 → whatsapp_python-3.0.6}/whatsapp/ext/_static.py +0 -0
@@ -0,0 +1 @@
1
+ 3.0.6
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: whatsapp-python
3
- Version: 3.0.4
3
+ Version: 3.0.6
4
4
  Summary: Open source Python wrapper for the WhatsApp Cloud API
5
5
  Project-URL: Homepage, https://github.com/filipporomani/whatsapp
6
6
  Project-URL: Bug Tracker, https://github.com/filipporomani/whatsapp/issues
@@ -9,5 +9,6 @@
9
9
 
10
10
  ## Reporting a Vulnerability
11
11
 
12
- Please report any vulnerability at Filippo Romani via e-mail: mail@filipporomani.it.
12
+ Please report any vulnerability via e-mail: mail@filipporomani.it.
13
13
  I'll review vulnerabilities as soon as possible, with maximum prioirity.
14
+ If you find any security issue that is not crucial, feel free to open an issue for it.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name="whatsapp-python"
7
- version="3.0.4"
7
+ version="3.0.6"
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"
@@ -25,4 +25,7 @@ classifiers=[
25
25
  [project.urls]
26
26
  "Homepage" = "https://github.com/filipporomani/whatsapp"
27
27
  "Bug Tracker" = "https://github.com/filipporomani/whatsapp/issues"
28
- "Download" = "https://github.com/filipporomani/whatsapp/releases/latest"
28
+ "Download" = "https://github.com/filipporomani/whatsapp/releases/latest"
29
+
30
+ [tool.hatch.build.targets.wheel]
31
+ packages = ["whatsapp"]
@@ -6,6 +6,7 @@ from __future__ import annotations
6
6
  import requests
7
7
  import logging
8
8
  from fastapi import FastAPI, Request
9
+ from uvicorn import run as _run
9
10
  from .constants import VERSION
10
11
  from . import ext
11
12
  from .ext._property import authorized
@@ -17,8 +18,6 @@ from .ext._buttons import send_button, create_button, send_reply_button
17
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
18
19
 
19
20
 
20
-
21
-
22
21
  class WhatsApp(object):
23
22
  def __init__(self, token: str = "", phone_number_id: str = "", logger: bool = True, update_check: bool = True):
24
23
  """
@@ -32,19 +31,25 @@ class WhatsApp(object):
32
31
 
33
32
  # Check if the version is up to date
34
33
  logging.getLogger(__name__).addHandler(logging.NullHandler())
35
-
36
34
 
37
35
  self.VERSION = VERSION
38
36
  if update_check is True:
39
37
  latest = str(requests.get(
40
38
  "https://pypi.org/pypi/whatsapp-python/json").json()["info"]["version"])
41
39
  if self.VERSION != latest:
42
- version_int = int(self.VERSION.replace(".", ""))
40
+ try:
41
+ version_int = int(self.VERSION.replace(".", ""))
42
+ except:
43
+ version_int = 0
43
44
  latest_int = int(latest.replace(".", ""))
44
45
  # this is to avoid the case where the version is 1.0.10 and the latest is 1.0.2 (possible if user is using the github version)
45
46
  if version_int < latest_int:
46
- logging.critical(
47
- f"Whatsapp-python is out of date. Please update to the latest version {latest}. READ THE CHANGELOG BEFORE UPDATING. NEW VERSIONS MAY BREAK YOUR CODE IF NOT PROPERLY UPDATED.")
47
+ if version_int == 0:
48
+ logging.critical(
49
+ f"There was an error while checking for updates, please update the package manually or report the issue on GitHub.")
50
+ else:
51
+ logging.critical(
52
+ f"Whatsapp-python is out of date. Please update to the latest version {latest}. READ THE CHANGELOG BEFORE UPDATING. NEW VERSIONS MAY BREAK YOUR CODE IF NOT PROPERLY UPDATED.")
48
53
  if version_int > latest_int:
49
54
  latest_beta = int(str(requests.get(
50
55
  "https://raw.githubusercontent.com/filipporomani/whatsapp/main/.version").text).replace(".", ""))
@@ -54,13 +59,17 @@ class WhatsApp(object):
54
59
  logging.critical(
55
60
  f"You are using a development version of whatsapp-python. Please report any issue on GitHub.")
56
61
 
57
- if token == "" or phone_number_id == "":
58
- logging.error("Token or phone number id not provided")
62
+
63
+ if token == "":
64
+ logging.error("Token not provided")
65
+ raise ValueError("Token not provided but required")
66
+ if phone_number_id == "":
67
+ logging.error("Phone number id not provided")
59
68
  raise ValueError(
60
- "Token or phone number ID not provided but is required")
69
+ "Phone number ID not provided but required")
61
70
  self.token = token
62
71
  self.phone_number_id = phone_number_id
63
- self.base_url = "https://graph.facebook.com/v17.0"
72
+ self.base_url = "https://graph.facebook.com/v18.0"
64
73
  self.url = f"{self.base_url}/{phone_number_id}/messages"
65
74
 
66
75
  async def base():
@@ -169,8 +178,8 @@ class WhatsApp(object):
169
178
  """
170
179
  self.verification_handler = handler
171
180
 
172
- def run(self, host: str = "localhost", port: int = 5000, debug: bool = False, **options):
173
- self.app.run(host=host, port=port, debug=debug, **options)
181
+ def run(self, host: str = "localhost", port: int = 5000, **options):
182
+ _run(self.app, host=host, port=port, **options)
174
183
 
175
184
 
176
185
  class Message(object):
@@ -0,0 +1,3 @@
1
+ # internal use only - numbers and . only
2
+
3
+ VERSION = "3.0.6"
@@ -1 +0,0 @@
1
- 3.0.1
@@ -1,85 +0,0 @@
1
- from whatsapp import Message, Hook, WhatsApp
2
- from flask import Response
3
- from os import getenv
4
- from dotenv import load_dotenv
5
-
6
-
7
- def handler(msg: Message):
8
- message_type = msg.type
9
- messenger = msg.instance
10
- mobile = msg.sender
11
-
12
- if message_type == "text":
13
- message = msg.content
14
- name = msg.name
15
- m = Message(instance=messenger, to=mobile, content="Hello World")
16
- m.send()
17
-
18
- elif message_type == "interactive":
19
- message_response = msg.interactive
20
- if message_response is None:
21
- return Response(status=400)
22
- interactive_type = message_response.get("type")
23
- message_id = message_response[interactive_type]["id"]
24
- message_text = message_response[interactive_type]["title"]
25
- # Do some action
26
-
27
- elif message_type == "location":
28
- message_location = msg.location
29
- if message_location is None:
30
- return Response(status=400)
31
- message_latitude = message_location["latitude"]
32
- message_longitude = message_location["longitude"]
33
- # Do some action
34
-
35
- elif message_type == "image":
36
- image = msg.image
37
- if image is None:
38
- return Response(status=400)
39
- image_id, mime_type = image["id"], image["mime_type"]
40
- image_url = messenger.query_media_url(image_id)
41
- if image_url is None:
42
- return Response(status=400)
43
- image_filename = messenger.download_media(image_url, mime_type)
44
- # Do some action
45
-
46
- elif message_type == "video":
47
- video = msg.video
48
- if video is None:
49
- return Response(status=400)
50
- video_id, mime_type = video["id"], video["mime_type"]
51
- video_url = messenger.query_media_url(video_id)
52
- if video_url is None:
53
- return Response(status=400)
54
- video_filename = messenger.download_media(video_url, mime_type)
55
- # Do some action
56
-
57
- elif message_type == "audio":
58
- audio = msg.audio
59
- if audio is None:
60
- return Response(status=400)
61
- audio_id, mime_type = audio["id"], audio["mime_type"]
62
- audio_url = messenger.query_media_url(audio_id)
63
- if audio_url is None:
64
- return Response(status=400)
65
- audio_filename = messenger.download_media(audio_url, mime_type)
66
- # Do some action
67
-
68
- elif message_type == "document":
69
- file = msg.document
70
- if file is None:
71
- return Response(status=400)
72
- file_id, mime_type = file["id"], file["mime_type"]
73
- file_url = messenger.query_media_url(file_id)
74
- if file_url is None:
75
- return Response(status=400)
76
- file_filename = messenger.download_media(file_url, mime_type)
77
- # Do some action
78
-
79
-
80
- messenger = WhatsApp(token=getenv("TOKEN"),
81
- phone_number_id=getenv("PHONE_NUMBER_ID"))
82
- hook = Hook(instance=messenger, handler=handler, port=5000,
83
- host="0.0.0.0", verify_token=getenv("VERIFY_TOKEN"))
84
-
85
- hook.run()
@@ -1,3 +0,0 @@
1
- # internal use only
2
-
3
- VERSION = "3.0.4"
File without changes