mirror of
https://github.com/EvolutionAPI/evolution-client-python.git
synced 2026-02-03 21:36:24 -06:00
adjusts in package
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
class BaseCall:
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update({k: v for k, v in kwargs.items() if v is not None})
|
||||
|
||||
class FakeCall(BaseCall):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
isVideo: bool,
|
||||
callDuration: int
|
||||
):
|
||||
super().__init__(
|
||||
number=number,
|
||||
isVideo=isVideo,
|
||||
callDuration=callDuration
|
||||
)
|
||||
@@ -0,0 +1,93 @@
|
||||
from typing import List, Optional, Dict, Any
|
||||
|
||||
class BaseChat:
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update({k: v for k, v in kwargs.items() if v is not None})
|
||||
|
||||
class CheckIsWhatsappNumber(BaseChat):
|
||||
def __init__(
|
||||
self,
|
||||
numbers: List[str]
|
||||
):
|
||||
super().__init__(
|
||||
numbers=numbers
|
||||
)
|
||||
|
||||
class MessageKey:
|
||||
def __init__(
|
||||
self,
|
||||
remote_jid: str,
|
||||
from_me: bool,
|
||||
id: str,
|
||||
participant: Optional[str] = None
|
||||
):
|
||||
self.remoteJid = remote_jid
|
||||
self.fromMe = from_me
|
||||
self.id = id
|
||||
self.participant = participant
|
||||
|
||||
class ReadMessage:
|
||||
def __init__(
|
||||
self,
|
||||
remote_jid: str,
|
||||
from_me: bool,
|
||||
id: str
|
||||
):
|
||||
self.remoteJid = remote_jid
|
||||
self.fromMe = from_me
|
||||
self.id = id
|
||||
|
||||
class ArchiveChat:
|
||||
def __init__(
|
||||
self,
|
||||
last_message: Dict[str, Any],
|
||||
chat: str,
|
||||
archive: bool
|
||||
):
|
||||
self.lastMessage = last_message
|
||||
self.chat = chat
|
||||
self.archive = archive
|
||||
|
||||
class UnreadChat:
|
||||
def __init__(
|
||||
self,
|
||||
last_message: Dict[str, Any],
|
||||
chat: str
|
||||
):
|
||||
self.lastMessage = last_message
|
||||
self.chat = chat
|
||||
|
||||
class ProfilePicture:
|
||||
def __init__(self, number: str):
|
||||
self.number = number
|
||||
|
||||
class MediaMessage:
|
||||
def __init__(
|
||||
self,
|
||||
message: Dict[str, Any],
|
||||
convert_to_mp4: bool = False
|
||||
):
|
||||
self.message = message
|
||||
self.convertToMp4 = convert_to_mp4
|
||||
|
||||
class UpdateMessage:
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
key: Dict[str, Any],
|
||||
text: str
|
||||
):
|
||||
self.number = number
|
||||
self.key = key
|
||||
self.text = text
|
||||
|
||||
class Presence:
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
delay: int,
|
||||
presence: str
|
||||
):
|
||||
self.number = number
|
||||
self.delay = delay
|
||||
self.presence = presence
|
||||
@@ -0,0 +1,39 @@
|
||||
from typing import List, Optional, Literal
|
||||
from dataclasses import dataclass
|
||||
|
||||
@dataclass
|
||||
class CreateGroup:
|
||||
subject: str
|
||||
participants: List[str]
|
||||
description: Optional[str] = None
|
||||
|
||||
@dataclass
|
||||
class GroupPicture:
|
||||
image: str
|
||||
|
||||
@dataclass
|
||||
class GroupSubject:
|
||||
subject: str
|
||||
|
||||
@dataclass
|
||||
class GroupDescription:
|
||||
description: str
|
||||
|
||||
@dataclass
|
||||
class GroupInvite:
|
||||
groupJid: str
|
||||
description: str
|
||||
numbers: List[str]
|
||||
|
||||
@dataclass
|
||||
class UpdateParticipant:
|
||||
action: Literal["add", "remove", "promote", "demote"]
|
||||
participants: List[str]
|
||||
|
||||
@dataclass
|
||||
class UpdateSetting:
|
||||
action: Literal["announcement", "not_announcement", "locked", "unlocked"]
|
||||
|
||||
@dataclass
|
||||
class ToggleEphemeral:
|
||||
expiration: int
|
||||
@@ -0,0 +1,59 @@
|
||||
from typing import Optional, List, Dict
|
||||
|
||||
class WebhookConfig:
|
||||
def __init__(self, url: str = None, byEvents: bool = False, base64: bool = True,
|
||||
headers: Dict = None, events: List[str] = None):
|
||||
self.url = url
|
||||
self.byEvents = byEvents
|
||||
self.base64 = base64
|
||||
self.headers = headers
|
||||
self.events = events
|
||||
|
||||
class EventsConfig:
|
||||
def __init__(self, enabled: bool = True, events: List[str] = None):
|
||||
self.enabled = enabled
|
||||
self.events = events
|
||||
|
||||
class ChatwootConfig:
|
||||
def __init__(self, accountId: str = None, token: str = None, url: str = None,
|
||||
signMsg: bool = True, reopenConversation: bool = True,
|
||||
conversationPending: bool = False, importContacts: bool = True,
|
||||
nameInbox: str = "evolution", mergeBrazilContacts: bool = True,
|
||||
importMessages: bool = True, daysLimitImportMessages: int = 3,
|
||||
organization: str = "Evolution Bot",
|
||||
logo: str = "https://evolution-api.com/files/evolution-api-favicon.png"):
|
||||
self.chatwootAccountId = accountId
|
||||
self.chatwootToken = token
|
||||
self.chatwootUrl = url
|
||||
self.chatwootSignMsg = signMsg
|
||||
self.chatwootReopenConversation = reopenConversation
|
||||
self.chatwootConversationPending = conversationPending
|
||||
self.chatwootImportContacts = importContacts
|
||||
self.chatwootNameInbox = nameInbox
|
||||
self.chatwootMergeBrazilContacts = mergeBrazilContacts
|
||||
self.chatwootImportMessages = importMessages
|
||||
self.chatwootDaysLimitImportMessages = daysLimitImportMessages
|
||||
self.chatwootOrganization = organization
|
||||
self.chatwootLogo = logo
|
||||
|
||||
class InstanceConfig:
|
||||
def __init__(
|
||||
self,
|
||||
instanceName: str,
|
||||
integration: str = None,
|
||||
token: str = None,
|
||||
number: str = None,
|
||||
qrcode: bool = None,
|
||||
rejectCall: bool = None,
|
||||
msgCall: str = None,
|
||||
groupsIgnore: bool = None,
|
||||
alwaysOnline: bool = None,
|
||||
readMessages: bool = None,
|
||||
readStatus: bool = None,
|
||||
syncFullHistory: bool = None
|
||||
):
|
||||
self.__dict__['instanceName'] = instanceName
|
||||
|
||||
for key, value in locals().items():
|
||||
if key != 'self' and key != 'instanceName' and value is not None:
|
||||
self.__dict__[key] = value
|
||||
@@ -0,0 +1,21 @@
|
||||
from typing import Literal
|
||||
|
||||
class BaseLabel:
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update({k: v for k, v in kwargs.items() if v is not None})
|
||||
|
||||
class HandleLabel(BaseLabel):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
label_id: str,
|
||||
action: Literal["add", "remove"]
|
||||
):
|
||||
if action not in ["add", "remove"]:
|
||||
raise ValueError("action deve ser 'add' ou 'remove'")
|
||||
|
||||
super().__init__(
|
||||
number=number,
|
||||
labelId=label_id,
|
||||
action=action
|
||||
)
|
||||
@@ -0,0 +1,254 @@
|
||||
from enum import Enum
|
||||
from typing import List, Optional, Union
|
||||
from dataclasses import dataclass
|
||||
|
||||
class MediaType(Enum):
|
||||
IMAGE = "image"
|
||||
VIDEO = "video"
|
||||
DOCUMENT = "document"
|
||||
|
||||
class StatusType(Enum):
|
||||
TEXT = "text"
|
||||
IMAGE = "image"
|
||||
VIDEO = "video"
|
||||
AUDIO = "audio"
|
||||
|
||||
class FontType(Enum):
|
||||
SERIF = 1
|
||||
NORICAN_REGULAR = 2
|
||||
BRYNDAN_WRITE = 3
|
||||
BEBASNEUE_REGULAR = 4
|
||||
OSWALD_HEAVY = 5
|
||||
|
||||
class BaseMessage:
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update({k: v for k, v in kwargs.items() if v is not None})
|
||||
|
||||
class QuotedMessage(BaseMessage):
|
||||
def __init__(self, key: dict, message: Optional[dict] = None):
|
||||
super().__init__(key=key, message=message)
|
||||
|
||||
class TextMessage(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
text: str,
|
||||
delay: Optional[int] = None,
|
||||
quoted: Optional[QuotedMessage] = None,
|
||||
linkPreview: Optional[bool] = None,
|
||||
mentionsEveryOne: Optional[bool] = None,
|
||||
mentioned: Optional[List[str]] = None
|
||||
):
|
||||
super().__init__(
|
||||
number=number,
|
||||
text=text,
|
||||
delay=delay,
|
||||
quoted=quoted.__dict__ if quoted else None,
|
||||
linkPreview=linkPreview,
|
||||
mentionsEveryOne=mentionsEveryOne,
|
||||
mentioned=mentioned
|
||||
)
|
||||
|
||||
class MediaMessage(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
mediatype: str,
|
||||
mimetype: str,
|
||||
caption: str,
|
||||
media: str,
|
||||
fileName: str,
|
||||
delay: Optional[int] = None,
|
||||
quoted: Optional[QuotedMessage] = None,
|
||||
mentionsEveryOne: Optional[bool] = None,
|
||||
mentioned: Optional[List[str]] = None
|
||||
):
|
||||
super().__init__(
|
||||
number=number,
|
||||
mediatype=mediatype,
|
||||
mimetype=mimetype,
|
||||
caption=caption,
|
||||
media=media,
|
||||
fileName=fileName,
|
||||
delay=delay,
|
||||
quoted=quoted.__dict__ if quoted else None,
|
||||
mentionsEveryOne=mentionsEveryOne,
|
||||
mentioned=mentioned
|
||||
)
|
||||
|
||||
class StatusMessage(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
type: StatusType,
|
||||
content: str,
|
||||
caption: Optional[str] = None,
|
||||
backgroundColor: Optional[str] = None,
|
||||
font: Optional[FontType] = None,
|
||||
allContacts: bool = False,
|
||||
statusJidList: Optional[List[str]] = None
|
||||
):
|
||||
super().__init__(
|
||||
type=type.value,
|
||||
content=content,
|
||||
caption=caption,
|
||||
backgroundColor=backgroundColor,
|
||||
font=font.value if font else None,
|
||||
allContacts=allContacts,
|
||||
statusJidList=statusJidList
|
||||
)
|
||||
|
||||
class LocationMessage(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
name: str,
|
||||
address: str,
|
||||
latitude: float,
|
||||
longitude: float,
|
||||
delay: Optional[int] = None,
|
||||
quoted: Optional[QuotedMessage] = None
|
||||
):
|
||||
super().__init__(
|
||||
number=number,
|
||||
name=name,
|
||||
address=address,
|
||||
latitude=latitude,
|
||||
longitude=longitude,
|
||||
delay=delay,
|
||||
quoted=quoted.__dict__ if quoted else None
|
||||
)
|
||||
|
||||
class Contact(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
fullName: str,
|
||||
wuid: str,
|
||||
phoneNumber: str,
|
||||
organization: Optional[str] = None,
|
||||
email: Optional[str] = None,
|
||||
url: Optional[str] = None
|
||||
):
|
||||
super().__init__(
|
||||
fullName=fullName,
|
||||
wuid=wuid,
|
||||
phoneNumber=phoneNumber,
|
||||
organization=organization,
|
||||
email=email,
|
||||
url=url
|
||||
)
|
||||
|
||||
class ContactMessage(BaseMessage):
|
||||
def __init__(self, number: str, contact: List[Contact]):
|
||||
super().__init__(
|
||||
number=number,
|
||||
contact=[c.__dict__ for c in contact]
|
||||
)
|
||||
|
||||
class ReactionMessage(BaseMessage):
|
||||
def __init__(self, key: dict, reaction: str):
|
||||
super().__init__(key=key, reaction=reaction)
|
||||
|
||||
class PollMessage(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
name: str,
|
||||
selectableCount: int,
|
||||
values: List[str],
|
||||
delay: Optional[int] = None,
|
||||
quoted: Optional[QuotedMessage] = None
|
||||
):
|
||||
super().__init__(
|
||||
number=number,
|
||||
name=name,
|
||||
selectableCount=selectableCount,
|
||||
values=values,
|
||||
delay=delay,
|
||||
quoted=quoted.__dict__ if quoted else None
|
||||
)
|
||||
|
||||
class ListRow(BaseMessage):
|
||||
def __init__(self, title: str, description: str, rowId: str):
|
||||
super().__init__(
|
||||
title=title,
|
||||
description=description,
|
||||
rowId=rowId
|
||||
)
|
||||
|
||||
class ListSection(BaseMessage):
|
||||
def __init__(self, title: str, rows: List[ListRow]):
|
||||
super().__init__(
|
||||
title=title,
|
||||
rows=[r.__dict__ for r in rows]
|
||||
)
|
||||
|
||||
class ListMessage(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
title: str,
|
||||
description: str,
|
||||
buttonText: str,
|
||||
footerText: str,
|
||||
sections: List[ListSection],
|
||||
delay: Optional[int] = None,
|
||||
quoted: Optional[QuotedMessage] = None
|
||||
):
|
||||
super().__init__(
|
||||
number=number,
|
||||
title=title,
|
||||
description=description,
|
||||
buttonText=buttonText,
|
||||
footerText=footerText,
|
||||
sections=[s.__dict__ for s in sections],
|
||||
delay=delay,
|
||||
quoted=quoted.__dict__ if quoted else None
|
||||
)
|
||||
|
||||
class Button(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
type: str,
|
||||
displayText: str,
|
||||
id: Optional[str] = None,
|
||||
copyCode: Optional[str] = None,
|
||||
url: Optional[str] = None,
|
||||
phoneNumber: Optional[str] = None,
|
||||
currency: Optional[str] = None,
|
||||
name: Optional[str] = None,
|
||||
keyType: Optional[str] = None,
|
||||
key: Optional[str] = None
|
||||
):
|
||||
super().__init__(
|
||||
type=type,
|
||||
displayText=displayText,
|
||||
id=id,
|
||||
copyCode=copyCode,
|
||||
url=url,
|
||||
phoneNumber=phoneNumber,
|
||||
currency=currency,
|
||||
name=name,
|
||||
keyType=keyType,
|
||||
key=key
|
||||
)
|
||||
|
||||
class ButtonMessage(BaseMessage):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
title: str,
|
||||
description: str,
|
||||
footer: str,
|
||||
buttons: List[Button],
|
||||
delay: Optional[int] = None,
|
||||
quoted: Optional[QuotedMessage] = None
|
||||
):
|
||||
super().__init__(
|
||||
number=number,
|
||||
title=title,
|
||||
description=description,
|
||||
footer=footer,
|
||||
buttons=[b.__dict__ for b in buttons],
|
||||
delay=delay,
|
||||
quoted=quoted.__dict__ if quoted else None
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
from enum import Enum
|
||||
|
||||
class PresenceStatus(Enum):
|
||||
AVAILABLE = "available"
|
||||
UNAVAILABLE = "unavailable"
|
||||
|
||||
class PresenceConfig:
|
||||
def __init__(self, presence: PresenceStatus):
|
||||
self.presence = presence.value
|
||||
@@ -0,0 +1,60 @@
|
||||
from typing import Literal
|
||||
|
||||
class BaseProfile:
|
||||
def __init__(self, **kwargs):
|
||||
self.__dict__.update({k: v for k, v in kwargs.items() if v is not None})
|
||||
|
||||
class FetchProfile(BaseProfile):
|
||||
def __init__(
|
||||
self,
|
||||
number: str,
|
||||
):
|
||||
super().__init__(
|
||||
number=number,
|
||||
)
|
||||
|
||||
class ProfileName(BaseProfile):
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
):
|
||||
super().__init__(
|
||||
name=name,
|
||||
)
|
||||
|
||||
class ProfileStatus(BaseProfile):
|
||||
def __init__(
|
||||
self,
|
||||
status: str,
|
||||
):
|
||||
super().__init__(
|
||||
status=status,
|
||||
)
|
||||
|
||||
class ProfilePicture(BaseProfile):
|
||||
def __init__(
|
||||
self,
|
||||
picture: str,
|
||||
):
|
||||
super().__init__(
|
||||
picture=picture,
|
||||
)
|
||||
|
||||
class PrivacySettings(BaseProfile):
|
||||
def __init__(
|
||||
self,
|
||||
readreceipts: Literal["all", "none"],
|
||||
profile: Literal["all", "contacts", "contact_blacklist", "none"],
|
||||
status: Literal["all", "contacts", "contact_blacklist", "none"],
|
||||
online: Literal["all", "match_last_seen"],
|
||||
last: Literal["all", "contacts", "contact_blacklist", "none"],
|
||||
groupadd: Literal["all", "contacts", "contact_blacklist"],
|
||||
):
|
||||
super().__init__(
|
||||
readreceipts=readreceipts,
|
||||
profile=profile,
|
||||
status=status,
|
||||
online=online,
|
||||
last=last,
|
||||
groupadd=groupadd,
|
||||
)
|
||||
Reference in New Issue
Block a user