Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ greenAPI = API.GreenAPI(
Link to example: [sendTextMessage.py](./examples/sync/sending/sendTextMessage.py).

```
response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text")
response = greenAPI.sending.sendMessage("79876543210@c.us", "Message text")

print(response.data)
```
Expand All @@ -74,7 +74,7 @@ Link to example: [sendMessageAsync.py](./examples/async/sending/sendMessageAsync
import asyncio

async def main():
response = await greenAPI.sending.sendMessageAsync("11001234567@c.us", "Message text")
response = await greenAPI.sending.sendMessageAsync("79876543210@c.us", "Message text")
print(response.data)

asyncio.run(main())
Expand All @@ -86,7 +86,7 @@ Link to example: [sendPictureByLink.py](./examples/sync/sending/sendPictureByLin

```
response = greenAPI.sending.sendFileByUrl(
"11001234567@c.us",
"79876543210@c.us",
"https://download.samplelib.com/png/sample-clouds2-400x300.png",
"sample-clouds2-400x300.png",
"Sample PNG"
Expand All @@ -101,7 +101,7 @@ Link to example: [sendPictureByUpload.py](./examples/sync/sending/sendPictureByU

```
response = greenAPI.sending.sendFileByUpload(
"11001234567@c.us",
"79876543210@c.us",
"data/logo.jpg",
"logo.jpg",
"Available rates"
Expand All @@ -119,7 +119,7 @@ import asyncio

async def main():
response = await greenAPI.sending.sendFileByUploadAsync(
"11001234567@c.us",
"79876543210@c.us",
"data/logo.jpg",
"logo.jpg",
"Available rates"
Expand All @@ -138,7 +138,7 @@ Link to example: [createGroupAndSendMessage.py](./examples/sync/createGroupAndSe

```
create_group_response = greenAPI.groups.createGroup(
"Group Name", ["11001234567@c.us"]
"Group Name", ["79876543210@c.us"]
)
if create_group_response.code == 200:
send_message_response = greenAPI.sending.sendMessage(
Expand Down Expand Up @@ -189,7 +189,7 @@ Link to example: [sendPoll.py](./examples/sync/sending/sendPoll.py).

```
response = greenAPI.sending.sendPoll(
"11001234567@c.us",
"79876543210@c.us",
"Please choose a color:",
[
{"optionName": "Red"},
Expand Down Expand Up @@ -221,13 +221,13 @@ Link to example: [sendInteractiveButtons.py](../examples/sync/sending/sendIntera

```
response = greenAPI.sending.sendInteractiveButtons(
"79001234567@c.us",
"79876543210@c.us",
"This is message with buttons!",
[{
"type": "call",
"buttonId": "1",
"buttonText": "Call me",
"phoneNumber": "79001234567"
"phoneNumber": "79876543210"
},
{
"type": "url",
Expand All @@ -251,13 +251,13 @@ import asyncio

async def main():
response = await greenAPI.sending.sendInteractiveButtonsAsync(
"79001234567@c.us",
"79876543210@c.us",
"This is message with buttons!",
[{
"type": "call",
"buttonId": "1",
"buttonText": "Call me",
"phoneNumber": "79001234567"
"phoneNumber": "79876543210"
},
{
"type": "url",
Expand Down Expand Up @@ -296,6 +296,8 @@ asyncio.run(main())
| Example of sending interactive buttons asynchronously | [SendInteractiveButtonsAsync.py](../examples/async/sending/sendInteractiveButtonsAsync.py) |
| Example of sending interactive buttons with a reply | [SendInteractiveButtonsReply.py](../examples/sync/sending/sendInteractiveButtonsReply.py) |
| Example of sending interactive buttons asynchronously with a reply | [SendInteractiveButtonsReplyAsync.py](../examples/async/sending/sendInteractiveButtonsReplyAsync.py) |
| Example of sending a notification about typing or recording audio | [SendTyping.py](../examples/sync/sendTyping.py) |
| Example of sending a notification about typing or recording audio asynchronously | [SendTypingAsync.py](../examples/async/sendTypingAsync.py) |

## The full list of the library methods

Expand Down Expand Up @@ -357,6 +359,7 @@ asyncio.run(main())
| `serviceMethods.archiveChat` | The method archives the chat | [ArchiveChat](https://green-api.com/en/docs/api/service/archiveChat/) |
| `serviceMethods.unarchiveChat` | The method unarchives the chat | [UnarchiveChat](https://green-api.com/en/docs/api/service/unarchiveChat/) |
| `serviceMethods.setDisappearingChat` | The method is designed to change the settings of disappearing messages in chats | [SetDisappearingChat](https://green-api.com/en/docs/api/service/SetDisappearingChat/) |
| `serviceMethods.sendTyping` | The method is intended to send a notification about typing or recording audio in the chat | [SendTyping](https://green-api.com/docs/api/service/SendTyping/) |
| `webhooks.startReceivingNotifications` | The method is designed to start receiving new notifications | |
| `webhooks.stopReceivingNotifications` | The method is designed to stop receiving new notifications | |
| `partner.GetInstances` | The method is for getting all the account instances created by the partner. | [GetInstances](https://green-api.com/en/docs/partners/getInstances/) |
Expand Down
25 changes: 14 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ greenAPI = API.GreenAPI(
Ссылка на пример: [sendTextMessage.py](../examples/sync/sending/sendTextMessage.py).

```
response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text")
response = greenAPI.sending.sendMessage("79876543210@c.us", "Message text")

print(response.data)
```
Expand All @@ -74,7 +74,7 @@ print(response.data)
import asyncio

async def main():
response = await greenAPI.sending.sendMessageAsync("11001234567@c.us", "Message text")
response = await greenAPI.sending.sendMessageAsync("79876543210@c.us", "Message text")
print(response.data)

asyncio.run(main())
Expand All @@ -86,7 +86,7 @@ asyncio.run(main())

```
response = greenAPI.sending.sendFileByUrl(
"11001234567@c.us",
"79876543210@c.us",
"https://download.samplelib.com/png/sample-clouds2-400x300.png",
"sample-clouds2-400x300.png",
"Sample PNG"
Expand All @@ -101,7 +101,7 @@ print(response.data)

```
response = greenAPI.sending.sendFileByUpload(
"11001234567@c.us",
"79876543210@c.us",
"data/logo.jpg",
"logo.jpg",
"Available rates"
Expand All @@ -120,7 +120,7 @@ import asyncio

async def main():
response = await greenAPI.sending.sendFileByUploadAsync(
"11001234567@c.us",
"79876543210@c.us",
"data/logo.jpg",
"logo.jpg",
"Available rates"
Expand All @@ -139,7 +139,7 @@ asyncio.run(main())

```
create_group_response = greenAPI.groups.createGroup(
"Group Name", ["11001234567@c.us"]
"Group Name", ["79876543210@c.us"]
)
if create_group_response.code == 200:
send_message_response = greenAPI.sending.sendMessage(
Expand Down Expand Up @@ -190,7 +190,7 @@ asyncio.run(main())

```
response = greenAPI.sending.sendPoll(
"11001234567@c.us",
"79876543210@c.us",
"Please choose a color:",
[
{"optionName": "Red"},
Expand Down Expand Up @@ -222,13 +222,13 @@ print(response.data)

```
response = greenAPI.sending.sendInteractiveButtons(
"79001234567@c.us",
"79876543210@c.us",
"This is message with buttons!",
[{
"type": "call",
"buttonId": "1",
"buttonText": "Call me",
"phoneNumber": "79001234567"
"phoneNumber": "79876543210"
},
{
"type": "url",
Expand All @@ -252,13 +252,13 @@ import asyncio

async def main():
response = await greenAPI.sending.sendInteractiveButtonsAsync(
"79001234567@c.us",
"79876543210@c.us",
"This is message with buttons!",
[{
"type": "call",
"buttonId": "1",
"buttonText": "Call me",
"phoneNumber": "79001234567"
"phoneNumber": "79876543210"
},
{
"type": "url",
Expand Down Expand Up @@ -297,6 +297,8 @@ asyncio.run(main())
| Пример асинхронной отправки интерактивных кнопок | [SendInteractiveButtonsAsync.py](../examples/async/sending/sendInteractiveButtonsAsync.py) |
| Пример отправки интерактивных кнопок с ответом | [SendInteractiveButtonsReply.py](../examples/sync/sending/sendInteractiveButtonsReply.py) |
| Пример асинхронной отправки интерактивных кнопок с ответом | [SendInteractiveButtonsReplyAsync.py](../examples/async/sending/sendInteractiveButtonsReplyAsync.py) |
| Пример отправки уведомления о наборе текста или записи аудио | [SendTyping.py](../examples/sync/sendTyping.py) |
| Пример асинхронной отправки уведомления о наборе текста или записи аудио | [SendTypingAsync.py](../examples/async/sendTypingAsync.py) |

## Полный список методов библиотеки

Expand Down Expand Up @@ -351,6 +353,7 @@ asyncio.run(main())
| `serviceMethods.archiveChat` | Метод архивирует чат | [ArchiveChat](https://green-api.com/docs/api/service/archiveChat/) |
| `serviceMethods.unarchiveChat` | Метод разархивирует чат | [UnarchiveChat](https://green-api.com/docs/api/service/unarchiveChat/) |
| `serviceMethods.setDisappearingChat` | Метод предназначен для изменения настроек исчезающих сообщений в чатах | [SetDisappearingChat](https://green-api.com/docs/api/service/SetDisappearingChat/) |
| `serviceMethods.sendTyping` | Метод предназначен для отправки уведомления о наборе текста или записи аудио в чат | [SendTyping](https://green-api.com/docs/api/service/SendTyping/) |
| `webhooks.startReceivingNotifications` | Метод предназначен для старта получения новых уведомлений | |
| `webhooks.stopReceivingNotifications` | Метод предназначен для остановки получения новых уведомлений | |
| `partner.GetInstances` | Метод предназначен для получения всех инстансов аккаунтов созданных партнёром. | [GetInstances](https://green-api.com/docs/partners/getInstances/) |
Expand Down
2 changes: 1 addition & 1 deletion examples/async/createGroupAndSendMessageAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

async def main():
create_group_response = await greenAPI.groups.createGroupAsync(
"SDK Python", ["11001234567@c.us", "11001234568@c.us"]
"SDK Python", ["79876543210@c.us", "11001234568@c.us"]
)

if create_group_response.code == 200:
Expand Down
4 changes: 2 additions & 2 deletions examples/async/groupsMethodsAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

async def main():
tasks = [
greenAPI.groups.createGroupAsync("SDK Python", ["11001234567@c.us", "11001234568@c.us"]),
greenAPI.groups.addGroupParticipantAsync("1234567890@g.us", "11001234567@c.us"),
greenAPI.groups.createGroupAsync("SDK Python", ["79876543210@c.us", "11001234568@c.us"]),
greenAPI.groups.addGroupParticipantAsync("1234567890@g.us", "79876543210@c.us"),
greenAPI.groups.getGroupDataAsync("1234567890@g.us")
]

Expand Down
8 changes: 4 additions & 4 deletions examples/async/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class GreenAPIDemo:
def __init__(self):
self.greenAPI = API.GreenAPI("1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345")
self.test_chat = "11001234567@c.us"
self.test_chat = "79876543210@c.us"

async def run_demo(self):
tasks = [
Expand Down Expand Up @@ -48,7 +48,7 @@ async def demo_contacts(self):
for i, contact in enumerate(contacts[:3]):
print(f" {i+1}. {contact.get('name', 'No name')} - {contact.get('id')}")

test_numbers = [79001234567, 79001234568]
test_numbers = [79876543210, 79001234568]
for number in test_numbers:
response = await self.greenAPI.serviceMethods.checkWhatsappAsync(number)
if response.code == 200:
Expand Down Expand Up @@ -86,7 +86,7 @@ async def demo_sending_messages(self):
print("Poll message sent: ", response.data)

contact = {
"phoneContact": 79001234567,
"phoneContact": 79876543210,
"firstName": "Jane",
"lastName": "Doe"
}
Expand All @@ -98,7 +98,7 @@ async def demo_sending_messages(self):
print("Contact message sent: ", response.data)

response = await self.greenAPI.sending.sendLocationAsync(
"79001234567@c.us",
"79876543210@c.us",
44.9370129,
89.8728409,
"Restaurant",
Expand Down
14 changes: 14 additions & 0 deletions examples/async/sendTypingAsync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import asyncio
from whatsapp_api_client_python import API

greenAPI = API.GreenAPI(
"1101000001", "d75b3a66374942c5b3c019c698abc2067e151558acbd412345"
)

async def main():
response = await greenAPI.serviceMethods.sendTypingAsync("79876543210@c.us", 5000, "recording")
if response.code == 200:
print(response.data)

if __name__ == '__main__':
asyncio.run(main())
6 changes: 4 additions & 2 deletions examples/async/sending/sendFileByUploadAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ async def main():
print(f"File {file_path} not found")
else:
response = await greenAPI.sending.sendFileByUploadAsync(
"11001234567@c.us",
"79876543210@c.us",
file_path,
"logo.jpg",
"logo"
"logo",
typingTime=5000,
typingType="recording"
)
if response.code == 200:
print(response.data)
Expand Down
2 changes: 1 addition & 1 deletion examples/async/sending/sendFileByUrlAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

async def main():
response = await greenAPI.sending.sendFileByUrlAsync(
"11001234567@c.us",
"79876543210@c.us",
"https://download.samplelib.com/png/sample-clouds2-400x300.png",
"sample-clouds2-400x300.png",
"Sample PNG"
Expand Down
4 changes: 2 additions & 2 deletions examples/async/sending/sendInteractiveButtonsAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

async def main():
response = await greenAPI.sending.sendInteractiveButtonsAsync(
"79001234567@c.us",
"79876543210@c.us",
"This is message with buttons!",
[{
"type": "call",
"buttonId": "1",
"buttonText": "Call me",
"phoneNumber": "79001234567"
"phoneNumber": "79876543210"
},
{
"type": "url",
Expand Down
2 changes: 1 addition & 1 deletion examples/async/sending/sendInteractiveButtonsReplyAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

async def main():
response = await greenAPI.sending.sendInteractiveButtonsReplyAsync(
"79001234567@c.us",
"79876543210@c.us",
"This is message with buttons!",
[{
"buttonId": "1",
Expand Down
2 changes: 1 addition & 1 deletion examples/async/sending/sendLocationAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

async def main():
response = await greenAPI.sending.sendLocationAsync(
"79001234567@c.us",
"79876543210@c.us",
44.9370129,
89.8728409,
"Restaurant",
Expand Down
2 changes: 1 addition & 1 deletion examples/async/sending/sendMessageAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
)

async def main():
response = await greenAPI.sending.sendMessageAsync("11001234567@c.us", "I use Green-API to send this message to you!")
response = await greenAPI.sending.sendMessageAsync("79876543210@c.us", "I use Green-API to send this message to you!", typingTime=5000)
if response.code == 200:
print(response.data)

Expand Down
2 changes: 1 addition & 1 deletion examples/async/sending/sendPollAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

async def main():
response = await greenAPI.sending.sendPollAsync(
"11001234567@c.us",
"79876543210@c.us",
"Please choose a color:",
[
{"optionName": "Red"},
Expand Down
2 changes: 1 addition & 1 deletion examples/async/sending/uploadFileAndSendFileByUrlAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def main():
file_name = os.path.basename(url.path)

send_file_response = await greenAPI.sending.sendFileByUrlAsync(
"11001234567@c.us", url_file, file_name
"79876543210@c.us", url_file, file_name
)

if send_file_response.code == 200:
Expand Down
8 changes: 4 additions & 4 deletions examples/async/serviceMethodsAsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

async def main():
tasks = [
greenAPI.serviceMethods.checkWhatsappAsync(79001234567),
greenAPI.serviceMethods.checkWhatsappAsync(79876543210),
greenAPI.serviceMethods.getContactsAsync(),
greenAPI.serviceMethods.deleteMessageAsync("11001234567@c.us", "BAE52A7F04F452F9", True),
greenAPI.serviceMethods.deleteMessageAsync("11001234567@c.us", "BAE52A7F04F452F9"),
greenAPI.serviceMethods.editMessageAsync("11001234567@c.us", "BAE5F793F61411D0", "Edited message text")
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)
Expand Down
Loading