-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathserviceMethodsAsync.py
More file actions
33 lines (29 loc) · 1.37 KB
/
Copy pathserviceMethodsAsync.py
File metadata and controls
33 lines (29 loc) · 1.37 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
import asyncio
from whatsapp_api_client_python import API
greenAPI = API.GreenAPI(
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
)
async def main():
tasks = [
# Preferred: use chatId
greenAPI.serviceMethods.checkWhatsappAsync(chatId="79876543210@c.us"),
# Bypass cache
greenAPI.serviceMethods.checkWhatsappAsync(chatId="79876543210@c.us", force=True),
# Old-style call still works (backward compatible)
greenAPI.serviceMethods.checkWhatsappAsync(79876543210),
# All contacts
greenAPI.serviceMethods.getContactsAsync(),
# Only groups
greenAPI.serviceMethods.getContactsAsync(group=True),
# Only personal chats, limit 20
greenAPI.serviceMethods.getContactsAsync(group=False, count=20),
# Last 10 active chats
greenAPI.serviceMethods.getChatsAsync(count=10),
greenAPI.serviceMethods.deleteMessageAsync("79876543210@c.us", "BAE52A7F04F452F9", True),
greenAPI.serviceMethods.deleteMessageAsync("79876543210@c.us", "BAE52A7F04F452F9"),
greenAPI.serviceMethods.editMessageAsync("79876543210@c.us", "BAE5F793F61411D0", "Edited message text")
]
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())