Skip to content

Commit 2b0a19e

Browse files
committed
updated hook.py and setup.py
1 parent 13d7a6f commit 2b0a19e

File tree

3 files changed

+59
-52
lines changed

3 files changed

+59
-52
lines changed

heyoo/__init__.py

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,8 @@
22
Unofficial python wrapper for the WhatsApp Cloud API.
33
"""
44

5-
import json
65
import requests
76

8-
# curl -X POST \
9-
# 'https://graph.facebook.com/v13.0/FROM_PHONE_NUMBER_ID/messages' \
10-
# -H 'Authorization: Bearer ACCESS_TOKEN' \
11-
# -d '{
12-
# "messaging_product": "whatsapp",
13-
# "recipient_type": "individual",
14-
# "to": "PHONE_NUMBER",
15-
# "type": "interactive",
16-
# "interactive": {
17-
# "type": "list",
18-
# "header": {
19-
# "type": "text",
20-
# "text": "HEADER_TEXT"
21-
# },
22-
# "body": {
23-
# "text": "BODY_TEXT"
24-
# },
25-
# "footer": {
26-
# "text": "FOOTER_TEXT"
27-
# },
28-
# "action": {
29-
# "button": "BUTTON_TEXT",
30-
# "sections": [
31-
# {
32-
# "title": "SECTION_2_TITLE",
33-
# "rows": [
34-
# {
35-
# "id": "SECTION_2_ROW_1_ID",
36-
# "title": "SECTION_2_ROW_1_TITLE",
37-
# "description": "SECTION_2_ROW_1_DESCRIPTION"
38-
# },
39-
# {
40-
# "id": "SECTION_2_ROW_2_ID",
41-
# "title": "SECTION_2_ROW_2_TITLE",
42-
# "description": "SECTION_2_ROW_2_DESCRIPTION"
43-
# }
44-
# ]
45-
# }
46-
# ]
47-
# }
48-
# }
49-
# }'
50-
517

528
class WhatsApp(object):
539
def __init__(self, token=None):
@@ -224,6 +180,11 @@ def get_message_timestamp(self, data):
224180
if "messages" in data:
225181
return data["messages"][0]["timestamp"]
226182

183+
def get_interactive_response(self, data):
184+
data = self.preprocess(data)
185+
if "messages" in data:
186+
return data["messages"][0]["interactive"]["list_reply"]
187+
227188
def get_message_type(self, data):
228189
data = self.preprocess(data)
229190
if "messages" in data:

hook.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ def hook():
2727
new_message = messenger.get_mobile(data)
2828
if new_message:
2929
mobile = messenger.get_mobile(data)
30-
message = messenger.get_message(data)
31-
name = messenger.get_name(data)
32-
print(f"{name} with this {mobile} number sent {message}")
33-
# messenger.send_message(f"Hi {name}, nice to connect with you", mobile)
34-
response = messenger.send_image(
35-
image_url="https://i.imgur.com/Fh7XVYY.jpeg", recipient_id=mobile
36-
)
37-
print(response)
30+
message_type = messenger.get_message_type(data)
31+
32+
if message_type == "text":
33+
message = messenger.get_message(data)
34+
name = messenger.get_name(data)
35+
print(f"{name} with this {mobile} number sent {message}")
36+
messenger.send_message(f"Hi {name}, nice to connect with you", mobile)
37+
38+
elif message_type == "interactive":
39+
message_response = messenger.get_interactive_response(data)
40+
print(message_response)
41+
42+
else:
43+
pass
3844
else:
3945
delivery = messenger.get_delivery(data)
4046
if delivery:

setup.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
from os import path
2+
from setuptools import setup
3+
4+
# read the contents of your description file
5+
6+
this_directory = path.abspath(path.dirname(__file__))
7+
with open(path.join(this_directory, "description.md"), encoding="utf-8") as f:
8+
long_description = f.read()
9+
10+
setup(
11+
name="heyoo",
12+
version="0.0.1",
13+
description="Opensource python wrapper to WhatsApp Cloud API",
14+
long_description=long_description,
15+
long_description_content_type="text/markdown",
16+
url="https://github.com/Neurotech-HQ/heyoo",
17+
download_url="",
18+
author="Jordan Kalebu",
19+
author_email="isaackeinstein@gmail.com",
20+
license="MIT",
21+
packages=["heyoo"],
22+
keywords=[
23+
"heyoo",
24+
"heyoo-libary",
25+
"WhatsApp Cloud API Wrapper",
26+
"PyWhatsApp",
27+
"WhatsApp API in Python",
28+
],
29+
python_requires=">=3.6",
30+
classifiers=[
31+
"Development Status :: 3 - Alpha",
32+
"Intended Audience :: Developers",
33+
"Topic :: Software Development :: Build Tools",
34+
"License :: OSI Approved :: MIT License",
35+
"Programming Language :: Python :: 3.6",
36+
"Programming Language :: Python :: 3.7",
37+
"Programming Language :: Python :: 3.8",
38+
"Programming Language :: Python :: 3.9",
39+
],
40+
)

0 commit comments

Comments
 (0)