-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathsendMessageWithPreviewAsync.py
More file actions
40 lines (35 loc) · 1.1 KB
/
Copy pathsendMessageWithPreviewAsync.py
File metadata and controls
40 lines (35 loc) · 1.1 KB
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
import asyncio
from whatsapp_api_client_python import API
greenAPI = API.GreenAPI(
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
)
async def main():
tasks = [
# Large link preview
greenAPI.sending.sendMessageAsync(
"79876543210@c.us",
"Check out our website!",
typePreview="large"
),
# Custom preview
greenAPI.sending.sendMessageAsync(
"79876543210@c.us",
"Check out our website!",
linkPreview=True,
customPreview={
"title": "My Website",
"description": "The best website in the world",
"link": "example.com"
}
),
# No preview
greenAPI.sending.sendMessageAsync(
"79876543210@c.us",
"https://example.com — visit us!",
linkPreview=False
),
]
responses = await asyncio.gather(*tasks, return_exceptions=True)
[print(response.data) for response in responses if response.code == 200]
if __name__ == '__main__':
asyncio.run(main())