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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/) |
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/) |
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
8 changes: 6 additions & 2 deletions whatsapp_api_client_python/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}."
Expand Down
17 changes: 17 additions & 0 deletions whatsapp_api_client_python/tools/serviceMethods.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down