Skip to content

Commit c622958

Browse files
committed
Add ForwardMessages method
1 parent d0948a0 commit c622958

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ Example of incoming webhooks receiving | [receiveNotification.py](https://github
159159
| `sending.sendLocation` | The method is aimed for sending a location message | [SendLocation.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendLocation.md) |
160160
| `sending.sendMessage` | The method is aimed for sending a text message to a personal or a group chat | [SendMessage.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendMessage.md) |
161161
| `sending.sendTemplateButtons` | The method is aimed for sending a message with template list interactive buttons to a personal or a group chat | [SendTemplateButtons.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendTemplateButtons.md) |
162+
| `sending.forwardMessages` | The method is intended for forwarding messages to a personal or group chat | [ForwardMessages.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/ForwardMessages.md) |
162163
| `serviceMethods.checkWhatsapp` | The method checks WhatsApp account availability on a phone number | [CheckWhatsapp.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/CheckWhatsapp.md) |
163164
| `serviceMethods.getAvatar` | The method returns a user or a group chat avatar | [GetAvatar.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/GetAvatar.md) |
164165
| `serviceMethods.getContactInfo` | The method is aimed for getting information on a contact | [GetContactInfo.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/GetContactInfo.md) |

README_RUS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ body | тело сообщения (json)
154154
| `sending.sendLocation` | Метод предназначен для отправки сообщения геолокации | [SendLocation.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendLocation.md) |
155155
| `sending.sendMessage` | Метод предназначен для отправки текстового сообщения в личный или групповой чат | [SendMessage.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendMessage.md) |
156156
| `sending.sendTemplateButtons` | Метод предназначен для отправки сообщения с интерактивными кнопками из перечня шаблонов в личный или групповой чат | [SendTemplateButtons.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/SendTemplateButtons.md) |
157+
| `sending.forwardMessages` | Метод предназначен для пересылки сообщений в личный или групповой чат | [ForwardMessages.md](https://github.com/green-api/docs/blob/master/ru/docs/api/sending/ForwardMessages.md) |
157158
| `serviceMethods.checkWhatsapp` | Метод проверяет наличие аккаунта WhatsApp на номере телефона | [CheckWhatsapp.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/CheckWhatsapp.md) |
158159
| `serviceMethods.getAvatar` | Метод возвращает аватар корреспондента или группового чата | [GetAvatar.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/GetAvatar.md) |
159160
| `serviceMethods.getContactInfo` | Метод предназначен для получения информации о контакте | [GetContactInfo.md](https://github.com/green-api/docs/blob/master/ru/docs/api/service/GetContactInfo.md) |

whatsapp_api_client_python/tools/sending.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,4 +280,25 @@ def sendTemplateButtons(self, chatId: str, message: str,
280280
return self.greenApi.request('POST',
281281
'{{host}}/waInstance{{idInstance}}'
282282
'/SendTemplateButtons/{{apiTokenInstance}}',
283-
requestBody)
283+
requestBody)
284+
285+
def forwardMessages(self, chatId: str, chatIdFrom: str,
286+
messages: array) -> Response:
287+
'The method is intended for forwarding messages to a personal or ' \
288+
'group chat. The forwarded messages will be added to the send queue.' \
289+
'Checking whatsapp authorization on the phone (i.e. availability in linked' \
290+
'devices) is not performed. The message will be kept for 24 hours ' \
291+
'in the queue and will be sent immediately after phone authorization. ' \
292+
'The rate at which messages are sent from the queue is managed by ' \
293+
'Message sending delay parameter.'
294+
295+
requestBody = {
296+
'chatId': chatId,
297+
'chatIdFrom': chatIdFrom,
298+
'messages': messages,
299+
}
300+
301+
return self.greenApi.request('POST',
302+
'{{host}}/waInstance{{idInstance}}'
303+
'/ForwardMessages/{{apiTokenInstance}}',
304+
requestBody)

0 commit comments

Comments
 (0)