diff --git a/.gitignore b/.gitignore index bd9a7b1..debe4f1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ # Python-generated files __pycache__/ -*.cpython*.pyc \ No newline at end of file +*.cpython*.pyc +evolutionapi.egg-info/ \ No newline at end of file diff --git a/build/lib/evolutionapi/services/chat.py b/build/lib/evolutionapi/services/chat.py index d4d3291..f1e06a5 100644 --- a/build/lib/evolutionapi/services/chat.py +++ b/build/lib/evolutionapi/services/chat.py @@ -1,4 +1,4 @@ -from typing import Union, BinaryIO +from typing import Union, BinaryIO, Optional from ..models.chat import * class ChatService: @@ -68,13 +68,53 @@ class ChatService: instance_token=instance_token ) - def get_messages(self, instance_id: str, remote_jid: str, instance_token: str, page: int = 1, offset: int = 50): - '''Get messages from a chat''' + def get_messages( + self, + instance_id: str, + remote_jid: str, + instance_token: str, + message_id: Optional[str] = None, + whatsapp_message_id: Optional[str] = None, + from_me: Optional[bool] = None, + message_type: Optional[str] = None, + source: Optional[str] = None, + timestamp_start: Optional[str] = None, + timestamp_end: Optional[str] = None, + page: int = 1, + offset: int = 50 + ): + ''' + Obtém mensagens de um chat com filtros opcionais + + Args: + timestamp_start: Data inicial no formato ISO (ex: "2025-01-16T00:00:00Z") + timestamp_end: Data final no formato ISO (ex: "2025-01-16T23:59:59Z") + ''' + where = {"key": {"remoteJid": remote_jid}} + + if message_id: + where["id"] = message_id + if whatsapp_message_id: + where["key"]["id"] = whatsapp_message_id + if from_me is not None: + where["key"]["fromMe"] = from_me + if message_type: + where["messageType"] = message_type + if source: + where["source"] = source + if timestamp_start or timestamp_end: + where["messageTimestamp"] = {} + if timestamp_start: + where["messageTimestamp"]["gte"] = timestamp_start + if timestamp_end: + where["messageTimestamp"]["lte"] = timestamp_end + payload = { - "where": {"key": {"remoteJid": remote_jid}}, + "where": where, "page": page, "offset": offset, } + return self.client.post( f'chat/findMessages/{instance_id}', data=payload, diff --git a/dist/evolutionapi-0.0.8.tar.gz b/dist/evolutionapi-0.0.8.tar.gz deleted file mode 100644 index a2fd111..0000000 Binary files a/dist/evolutionapi-0.0.8.tar.gz and /dev/null differ diff --git a/dist/evolutionapi-0.0.8-py3-none-any.whl b/dist/evolutionapi-0.0.9-py3-none-any.whl similarity index 82% rename from dist/evolutionapi-0.0.8-py3-none-any.whl rename to dist/evolutionapi-0.0.9-py3-none-any.whl index f087113..36c5830 100644 Binary files a/dist/evolutionapi-0.0.8-py3-none-any.whl and b/dist/evolutionapi-0.0.9-py3-none-any.whl differ diff --git a/dist/evolutionapi-0.0.9.tar.gz b/dist/evolutionapi-0.0.9.tar.gz new file mode 100644 index 0000000..4f6686b Binary files /dev/null and b/dist/evolutionapi-0.0.9.tar.gz differ diff --git a/evolutionapi.egg-info/PKG-INFO b/evolutionapi.egg-info/PKG-INFO deleted file mode 100644 index 7256c32..0000000 --- a/evolutionapi.egg-info/PKG-INFO +++ /dev/null @@ -1,9 +0,0 @@ -Metadata-Version: 2.1 -Name: evolutionapi -Version: 0.0.8 -Summary: Client Python para a API Evolution -Author: Davidson Gomes -Author-email: contato@agenciadgcode.com -Requires-Python: >=3.6 -Requires-Dist: requests>=2.25.1 -Requires-Dist: requests_toolbelt>=1.0.0 diff --git a/evolutionapi.egg-info/SOURCES.txt b/evolutionapi.egg-info/SOURCES.txt deleted file mode 100644 index e8a8b5b..0000000 --- a/evolutionapi.egg-info/SOURCES.txt +++ /dev/null @@ -1,28 +0,0 @@ -README.md -setup.py -evolutionapi/__init__.py -evolutionapi/client.py -evolutionapi/exceptions.py -evolutionapi.egg-info/PKG-INFO -evolutionapi.egg-info/SOURCES.txt -evolutionapi.egg-info/dependency_links.txt -evolutionapi.egg-info/requires.txt -evolutionapi.egg-info/top_level.txt -evolutionapi/models/__init__.py -evolutionapi/models/call.py -evolutionapi/models/chat.py -evolutionapi/models/group.py -evolutionapi/models/instance.py -evolutionapi/models/label.py -evolutionapi/models/message.py -evolutionapi/models/presence.py -evolutionapi/models/profile.py -evolutionapi/services/__init__.py -evolutionapi/services/call.py -evolutionapi/services/chat.py -evolutionapi/services/group.py -evolutionapi/services/instance.py -evolutionapi/services/instance_operations.py -evolutionapi/services/label.py -evolutionapi/services/message.py -evolutionapi/services/profile.py \ No newline at end of file diff --git a/evolutionapi.egg-info/dependency_links.txt b/evolutionapi.egg-info/dependency_links.txt deleted file mode 100644 index 8b13789..0000000 --- a/evolutionapi.egg-info/dependency_links.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/evolutionapi.egg-info/requires.txt b/evolutionapi.egg-info/requires.txt deleted file mode 100644 index 031d8e7..0000000 --- a/evolutionapi.egg-info/requires.txt +++ /dev/null @@ -1,2 +0,0 @@ -requests>=2.25.1 -requests_toolbelt>=1.0.0 diff --git a/evolutionapi.egg-info/top_level.txt b/evolutionapi.egg-info/top_level.txt deleted file mode 100644 index 74af2d6..0000000 --- a/evolutionapi.egg-info/top_level.txt +++ /dev/null @@ -1 +0,0 @@ -evolutionapi