-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_webhook.py
50 lines (43 loc) · 1.46 KB
/
send_webhook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import requests
import json
# The URL of the locally running Flask server
# url = 'http://localhost:8000/webhook'
# url = 'http://0.0.0.0:8000/webhook'
url = 'http://127.0.0.1:8000/webhook'
# payload = {
# "update_id":1111111111,"message":{"message_id":2222,"from":{"id":333333333333,"is_bot":false,"first_name":"Username","last_name":"Lastname","username":"username","language_code":"en},"chat":{"id":1111111111,"first_name":"Username","last_name":"Lastname","username":"username","type":"private"},"date":1518592199,"text":"xyz"}
# }
# }}
# Sample payload mimicking the webhook data
# Sample payload mimicking the webhook data
payload = {
"update_id": 74838539,
"message": {
"date": 1441645532,
"chat": {
"last_name": "NAME",
"id": 85393958985,
"first_name": "NAME",
"username": "NAME",
"type": "private" # Add this field
},
"message_id": 7487,
"from": {
"last_name": "NAME",
"id": 85393958985,
"first_name": "NAME",
"username": "NAME",
"is_bot": False # Add this field
},
"text": "/start"
}
}
# Headers
headers = {
'Content-Type': 'application/json'
}
# Send the POST request
response = requests.post(url, headers=headers, data=json.dumps(payload))
# Print the response
print(response.status_code)
print(response.text)