Skip to content

Commit 7693037

Browse files
committed
webhooks
1 parent a9e9e5e commit 7693037

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

.vscode/launch.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
// Используйте IntelliSense, чтобы узнать о возможных атрибутах.
3+
// Наведите указатель мыши, чтобы просмотреть описания существующих атрибутов.
4+
// Для получения дополнительной информации посетите: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python: текущий файл",
9+
"type": "python",
10+
"request": "launch",
11+
"program": "${file}",
12+
"console": "integratedTerminal",
13+
"justMyCode": false
14+
}
15+
]
16+
}

setup.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import setuptools
2+
3+
with open("README.md") as file:
4+
read_me_description = file.read()
5+
6+
setuptools.setup(
7+
name="whatsapp-api-webhook-server-python",
8+
version="0.0.3",
9+
install_requires=[],
10+
author="Ivan Sadovy",
11+
author_email="sadiv@bk.ru",
12+
description="This library helps you easily create a python '\
13+
'server application to get webhooks the WhatsApp API events '\
14+
'using service green-api.com",
15+
long_description=read_me_description,
16+
long_description_content_type="text/markdown",
17+
url="https://github.com/green-api/whatsapp-api-webhook-server-python",
18+
packages=['whatsapp_api_webhook_server_python'],
19+
classifiers=[
20+
"Programming Language :: Python :: 3",
21+
"License :: OSI Approved :: MIT License",
22+
"Operating System :: OS Independent",
23+
],
24+
python_requires='>=3.5',
25+
)

whatsapp_api_webhook_server_python/__init__.py

Whitespace-only changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import json
2+
from ast import literal_eval
3+
from enum import Enum
4+
5+
6+
class TypeWebhook(Enum):
7+
INCOMING_MESSAGE_RECEIVED = 'incomingMessageReceived'
8+
OUTGOING_MESSAGE_RECEIVED = 'outgoingMessageReceived'
9+
OUTGOING_API_MESSAGE_RECEIVED = 'outgoingAPIMessageReceived'
10+
OUTGOING_MESSAGE_STATUS = 'outgoingMessageStatus'
11+
STATE_INSTANCE_CHANGED = 'stateInstanceChanged'
12+
STATUS_INSTANCE_CHANGED = 'statusInstanceChanged'
13+
DEVICE_INFO = 'deviceInfo'
14+
INCOMING_CALL = 'incomingCall'
15+
16+
class Webhooks():
17+
18+
def webhookProccessing(dataText, onEvent):
19+
try:
20+
data = json.loads(dataText)
21+
except:
22+
return
23+
body = data['body']
24+
typeWebhook = body['typeWebhook']
25+
onEvent(typeWebhook, body)

0 commit comments

Comments
 (0)