Skip to content

Commit a98ae2c

Browse files
SDK-36: Требуется добавить поддержку кнопок в SDK Python
add sendInteractiveButtons, sendInteractiveButtonsReply in sync and async
1 parent 372160b commit a98ae2c

File tree

13 files changed

+346
-32
lines changed

13 files changed

+346
-32
lines changed

README.md

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ greenAPI = API.GreenAPI(
5858

5959
### Sending a text message to a WhatsApp number
6060

61-
Link to example: [sendTextMessage.py](./examples/sync/sendTextMessage.py).
61+
Link to example: [sendTextMessage.py](./examples/sync/sending/sendTextMessage.py).
6262

6363
```
6464
response = greenAPI.sending.sendMessage("11001234567@c.us", "Message text")
@@ -82,7 +82,7 @@ asyncio.run(main())
8282

8383
### Sending an image via URL
8484

85-
Link to example: [sendPictureByLink.py](./examples/sync/sendPictureByLink.py).
85+
Link to example: [sendPictureByLink.py](./examples/sync/sending/sendPictureByLink.py).
8686

8787
```
8888
response = greenAPI.sending.sendFileByUrl(
@@ -97,7 +97,7 @@ print(response.data)
9797

9898
### Sending an image by uploading from the disk
9999

100-
Link to example: [sendPictureByUpload.py](./examples/sync/sendPictureByUpload.py).
100+
Link to example: [sendPictureByUpload.py](./examples/sync/sending/sendPictureByUpload.py).
101101

102102
```
103103
response = greenAPI.sending.sendFileByUpload(
@@ -185,7 +185,7 @@ asyncio.run(main())
185185

186186
### Sending a polling message
187187

188-
Link to example: [sendPoll.py](./examples/sync/sendPoll.py).
188+
Link to example: [sendPoll.py](./examples/sync/sending/sendPoll.py).
189189

190190
```
191191
response = greenAPI.sending.sendPoll(
@@ -215,26 +215,87 @@ response = greenAPI.statuses.sendTextStatus(
215215
print(response.data)
216216
```
217217

218+
### Sending interactive buttons
219+
220+
Link to example: [sendInteractiveButtons.py](../examples/sync/sending/sendInteractiveButtons.py).
221+
222+
```
223+
response = greenAPI.sending.sendInteractiveButtons(
224+
"79001234567@c.us",
225+
"This is message with buttons!",
226+
[{
227+
"type": "call",
228+
"buttonId": "1",
229+
"buttonText": "Call me",
230+
"phoneNumber": "79001234567"
231+
},
232+
{
233+
"type": "url",
234+
"buttonId": "2",
235+
"buttonText": "Green-api",
236+
"url": "https://green-api.com/en/docs/api/sending/SendInteractiveButtons/"
237+
}],
238+
"Check this out",
239+
"Hope you like it"
240+
)
241+
242+
print(response.data)
243+
```
244+
245+
### Sending interactive buttons async
246+
247+
Link to example: [sendInteractiveButtonsAsync.py](../examples/async/sending/sendInteractiveButtonsAsync.py).
248+
249+
```
250+
import asyncio
251+
252+
async def main():
253+
response = await greenAPI.sending.sendInteractiveButtonsAsync(
254+
"79001234567@c.us",
255+
"This is message with buttons!",
256+
[{
257+
"type": "call",
258+
"buttonId": "1",
259+
"buttonText": "Call me",
260+
"phoneNumber": "79001234567"
261+
},
262+
{
263+
"type": "url",
264+
"buttonId": "2",
265+
"buttonText": "Green-api",
266+
"url": "https://green-api.com/en/docs/api/sending/SendInteractiveButtons/"
267+
}],
268+
"Check this out",
269+
"Hope you like it"
270+
)
271+
print(response.data)
272+
asyncio.run(main())
273+
```
274+
218275
## Examples list
219276

220277
| Description | Module |
221278
|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------|
222-
| Example of sending text | [sendTextMessage.py](./examples/sync/sendTextMessage.pyy) |
279+
| Example of sending text | [sendTextMessage.py](./examples/sync/sending/sendTextMessage.pyy) |
223280
| Example of sending text asynchronously | [sendTextMessageAsync.py](./examples/async/sendMessageAsync.py) |
224-
| Example of sending a picture by URL | [sendPictureByLink.py](./examples/sync/sendPictureByLink.py) |
281+
| Example of sending a picture by URL | [sendPictureByLink.py](./examples/sync/sending/sendPictureByLink.py) |
225282
| Example of sending a file by URL asynchronously | [sendFileByUrlAsync.py](./examples/async/sending/sendFileByUrlAsync.py) |
226-
| Example of sending a picture by uploading from the disk | [sendPictureByUpload.py](./examples/sync/sendPictureByUpload.py) |
283+
| Example of sending a picture by uploading from the disk | [sendPictureByUpload.py](./examples/sync/sending/sendPictureByUpload.py) |
227284
| Example of sending file by uploading from the disk asynchronously | [sendFileByUploadAsync.py](./examples/async/sending/sendFileByUploadAsync.py) |
228-
| Example of a group creation and sending a message to the group | [createGroupAndSendMessage.py](./examples/sync/createGroupAndSendMessage.py) |
285+
| Example of a group creation and sending a message to the group | [createGroupAndSendMessage.py](./examples/sync/sending/createGroupAndSendMessage.py) |
229286
| Example of a group creation and sending a message to the group asynchronously | [createGroupAndSendMessageAsync.py](./examples/async/createGroupAndSendMessageAsync.py) |
230287
| Example of incoming webhooks receiving | [receiveNotification.py](./examples/sync/receiveNotification.py) |
231288
| Example of incoming webhooks receiving asynchronously | [receiveNotificationAsync.py](./examples/async/receiveNotificationAsync.py) |
232-
| Example of sending a polling message | [sendPoll.py](./examples/sync/sendPoll.py) |
289+
| Example of sending a polling message | [sendPoll.py](./examples/sync/sending/sendPoll.py) |
233290
| Example of sending a polling message asynchronously | [sendPollAsync.py](./examples/async/sending/sendPollasync.py) |
234291
| Example of sending a text status | [sendTextStatus.py](./examples/sync/statusesMethods/sendTextStatus.py) |
235292
| Example of sending a text status asynchronously | [sendTextStatusAsync.py](./examples/async/statusesMethods/sendTextStatusAsync.py) |
236293
| Example of creating instance | [CreateInstance.py](./examples/sync/partherMethods/CreateInstance.py) |
237294
| Example of creating instance asynchronously | [CreateInstanceAsync.py](./examples/async/partherMethods/CreateInstanceAsync.py) |
295+
| Example of sending interactive buttons | [SendInteractiveButtons.py](../examples/sync/sending/sendInteractiveButtons.py) |
296+
| Example of sending interactive buttons asynchronously | [SendInteractiveButtonsAsync.py](../examples/async/sending/sendInteractiveButtonsAsync.py) |
297+
| Example of sending interactive buttons with a reply | [SendInteractiveButtonsReply.py](../examples/sync/sending/sendInteractiveButtonsReply.py) |
298+
| Example of sending interactive buttons asynchronously with a reply | [SendInteractiveButtonsReplyAsync.py](../examples/async/sending/sendInteractiveButtonsReplyAsync.py) |
238299

239300
## The full list of the library methods
240301

@@ -278,17 +339,15 @@ print(response.data)
278339
| `receiving.deleteNotification` | The method is designed to remove an incoming notification from the notification queue | [DeleteNotification](https://green-api.com/en/docs/api/receiving/technology-http-api/DeleteNotification/) |
279340
| `receiving.downloadFile` | The method is for downloading received and sent files | [DownloadFile](https://green-api.com/en/docs/api/receiving/files/DownloadFile/) |
280341
| `sending.sendMessage` | The method is designed to send a text message to a personal or group chat | [SendMessage](https://green-api.com/en/docs/api/sending/SendMessage/) |
281-
| `sending.sendButtons` | The method is designed to send a message with buttons to a personal or group chat | [SendButtons](https://green-api.com/en/docs/api/sending/SendButtons/) |
282-
| `sending.sendTemplateButtons` | The method is designed to send a message with interactive buttons from the list of templates in a personal or group chat | [SendTemplateButtons](https://green-api.com/en/docs/api/sending/SendTemplateButtons/) |
283-
| `sending.sendListMessage` | The method is designed to send a message with a selection button from a list of values to a personal or group chat | [SendListMessage](https://green-api.com/en/docs/api/sending/SendListMessage/) |
284342
| `sending.sendFileByUpload` | The method is designed to send a file loaded through a form (form-data) | [SendFileByUpload](https://green-api.com/en/docs/api/sending/SendFileByUpload/) |
285343
| `sending.sendFileByUrl` | The method is designed to send a file downloaded via a link | [SendFileByUrl](https://green-api.com/en/docs/api/sending/SendFileByUrl/) |
286344
| `sending.uploadFile` | The method is designed to upload a file to the cloud storage, which can be sent using the sendFileByUrl method | [UploadFile](https://green-api.com/en/docs/api/sending/UploadFile/) |
287345
| `sending.sendLocation` | The method is designed to send a geolocation message | [SendLocation](https://green-api.com/en/docs/api/sending/SendLocation/) |
288346
| `sending.sendContact` | The method is for sending a message with a contact | [SendContact](https://green-api.com/en/docs/api/sending/SendContact/) |
289-
| `sending.sendLink` | The method is designed to send a message with a link that will add an image preview, title and description | [SendLink](https://green-api.com/en/docs/api/sending/SendLink/) |
290347
| `sending.forwardMessages` | The method is designed for forwarding messages to a personal or group chat | [ForwardMessages](https://green-api.com/en/docs/api/sending/ForwardMessages/) |
291348
| `sending.sendPoll` | The method is designed for sending messages with a poll to a private or group chat | [SendPoll](https://green-api.com/en/docs/api/sending/SendPoll/) |
349+
| `sending.sendInteractiveButtons` | This method is used to send messages with interactive buttons | [sendInteractiveButtons](https://green-api.com/en/docs/api/sending/SendInteractiveButtons/) |
350+
| `sending.sendInteractiveButtonsReply` | This method is used to send messages with interactive buttons with a reply | [sendInteractiveButtonsReply](https://green-api.com/en/docs/api/sending/SendInteractiveButtonsReply/) |
292351
| `serviceMethods.checkWhatsapp` | The method checks if there is a WhatsApp account on the phone number | [CheckWhatsapp](https://green-api.com/en/docs/api/service/CheckWhatsapp/) |
293352
| `serviceMethods.getAvatar` | The method returns the avatar of the correspondent or group chat | [GetAvatar](https://green-api.com/en/docs/api/service/GetAvatar/) |
294353
| `serviceMethods.getContacts` | The method is designed to get a list of contacts of the current account | [GetContacts](https://green-api.com/en/docs/api/service/GetContacts/) |

0 commit comments

Comments
 (0)