diff --git a/README.md b/README.md index 164f1da..d9704f4 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,7 @@ print(response.data) | `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/) | | `serviceMethods.getContactInfo` | The method is designed to obtain information about the contact | [GetContactInfo](https://green-api.com/en/docs/api/service/GetContactInfo/) | | `serviceMethods.deleteMessage` | The method deletes the message from chat | [DeleteMessage](https://green-api.com/en/docs/api/service/deleteMessage/) | +| `serviceMethods.editMessage` | The method edits the message in chat | [EditMessage](https://green-api.com/en/docs/api/service/editMessage/) | | `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/) | diff --git a/docs/README.md b/docs/README.md index f6a7f02..d8127a7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -215,6 +215,7 @@ print(response.data) | `serviceMethods.getContacts` | Метод предназначен для получения списка контактов текущего аккаунта | [GetContacts](https://green-api.com/docs/api/service/GetContacts/) | | `serviceMethods.getContactInfo` | Метод предназначен для получения информации о контакте | [GetContactInfo](https://green-api.com/docs/api/service/GetContactInfo/) | | `serviceMethods.deleteMessage` | Метод удаляет сообщение из чата | [DeleteMessage](https://green-api.com/docs/api/service/deleteMessage/) | +| `serviceMethods.editMessage` | Метод изменяет сообщение в чате | [EditMessage](https://green-api.com/docs/api/service/editMessage/) | | `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/) | diff --git a/setup.py b/setup.py index c890ff3..1c92486 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="whatsapp-api-client-python", - version="0.0.48", + version="0.0.49", description=( "This library helps you easily create" " a Python application with WhatsApp API." diff --git a/whatsapp_api_client_python/API.py b/whatsapp_api_client_python/API.py index 4449db9..62a2612 100644 --- a/whatsapp_api_client_python/API.py +++ b/whatsapp_api_client_python/API.py @@ -78,14 +78,18 @@ def request( url = url.replace("{{idInstance}}", self.idInstance) url = url.replace("{{apiTokenInstance}}", self.apiTokenInstance) + headers = { + 'User-Agent': 'GREEN-API_SDK_PY/1.0' + } + try: if not files: response = self.session.request( - method=method, url=url, json=payload, timeout=self.host_timeout + method=method, url=url, json=payload, timeout=self.host_timeout, headers=headers ) else: response = self.session.request( - method=method, url=url, data=payload, files=files, timeout=self.media_timeout + method=method, url=url, data=payload, files=files, timeout=self.media_timeout, headers=headers ) except Exception as error: error_message = f"Request was failed with error: {error}." diff --git a/whatsapp_api_client_python/tools/serviceMethods.py b/whatsapp_api_client_python/tools/serviceMethods.py index 1ceab7f..06834ad 100644 --- a/whatsapp_api_client_python/tools/serviceMethods.py +++ b/whatsapp_api_client_python/tools/serviceMethods.py @@ -94,6 +94,23 @@ def deleteMessage(self, chatId: str, idMessage: str) -> Response: ), request_body ) + def editMessage(self, chatId: str, idMessage: str, message: str) -> Response: + """ + The method edits a message in chat. + + https://green-api.com/en/docs/api/service/editMessage/ + """ + + request_body = locals() + request_body.pop("self") + + return self.api.request( + "POST", ( + "{{host}}/waInstance{{idInstance}}/" + "editMessage/{{apiTokenInstance}}" + ), request_body + ) + def archiveChat(self, chatId: str) -> Response: """ The method archives a chat.