class Participant(BaseModel): is_admin = BooleanField(default=False) """ Whether the participant is a group administrator or not. """ is_super_admin = BooleanField() """
class NotificationMessage(BaseMessage): # group notifications recipients = ArrayField(field_type=StringIdField()) broadcast = BooleanField(default=False) multicast = BooleanField(default=False) url_text = StringIdField() url_number = IntegerField()
class ChatState(BaseModel): class Type(Enum): AVAILABLE = 'available' UNAVAILABLE = 'unavailable' COMPOSING = 'composing' RECORDING = 'recording' deny = BooleanField() is_state = BooleanField() timestamp = DateTimeField(alias=['t']) update_time = DateTimeField() type = EnumField(enum_class=Type)
class GroupNotificationMessage(BaseMessage): """ Notification message. """ __default_data__ = {'type': MessageTypes.GROUP_NOTIFICATION} # group notifications recipients = ArrayField(field_type=StringIdField()) broadcast = BooleanField(default=False) multicast = BooleanField(default=False) url_text = StringIdField() url_number = IntegerField()
class LinkContentMixin(BaseModel): matched_text = StringIdField() """ Piece of text which match with link. """ canonical_url = StringIdField() """ Canonical url. """ description = StringIdField() """ Page description. """ title = StringIdField() """ Page title. """ thumbnail = Base64Field() """ Page thumbnail. """ link_preview = BooleanField(default=False) """ Whether there is a thumbnail or not. """ links = ArrayField(field_type=StringIdField()) """
class LocationMessage(QuotedMessageMixin, MentionsMixin, BaseMessage): """ Location message. """ __default_data__ = {'type': MessageTypes.LOCATION} body = Base64Field() is_live = BooleanField(default=False) lat = FloatField() lng = FloatField() loc = StringIdField() accuracy = IntegerField() speed = IntegerField() degrees = FloatField() comment = StringIdField() sequence = DateTimeField() share_duration = TimedeltaField() duration = TimedeltaField() text = StringIdField() final_thumbnail = Base64Field() final_lat = FloatField() final_lng = FloatField() final_accuracy = IntegerField() final_speed = IntegerField() final_degrees = FloatField() final_time_offset = TimedeltaField()
class Mute(BaseModel): """ Mute model. """ expiration = DateTimeField() """ Expiration date time. """ is_muted = BooleanField() """ Whether it is already muted or not. """ is_state = BooleanField() """
class LinkContentMixin(BaseModel): matched_text = StringIdField() canonical_url = StringIdField() description = StringIdField() title = StringIdField() thumbnail = Base64Field() link_preview = BooleanField(default=False) links = ArrayField(field_type=StringIdField())
class MediaMixin(BaseModel): client_url = StringIdField() direct_path = StringIdField() mimetype = StringIdField() caption = StringIdField() filehash = StringIdField() size = IntegerField() media_key = StringIdField() is_unsent_media = BooleanField(default=False)
class Chat(BaseModel): name = StringIdField() last_message_ts = DateTimeField(name='t') pin = IntegerField() unread_count = IntegerField() archive = BooleanField(default=False) change_number_new_jid = StringIdField() change_number_old_jid = StringIdField() contact = ModelField(model_class=Contact) group_metadata = ModelField(model_class=GroupMetadata) is_announce_grp_restrict = BooleanField(default=False) is_group = BooleanField(default=False) is_read_only = BooleanField(default=False) kind = StringIdField() last_received_key = StringIdField() modify_tag = StringIdField() mute_expiration = IntegerField() not_spam = BooleanField(default=False)
class MediaMixin(BaseModel): type = EnumField(enum_class=MessageTypes, read_only=True) client_url = StringIdField() direct_path = StringIdField() mimetype = StringIdField() caption = StringIdField() filehash = StringIdField() size = IntegerField() media_key = StringIdField() is_unsent_media = BooleanField(default=False)
class TextMessage(QuotedMessageMixin, LinkContentMixin, MentionsMixin, BaseMessage): """ Text message. """ __default_data__ = {'type': MessageTypes.CHAT} text_color = StringIdField() background_color = StringIdField() font = StringIdField() contains_emoji = BooleanField(default=False)
class LocationMessage(QuotedMessageMixin, MentionsMixin, BaseMessage): body = Base64Field() lat = FloatField() lng = FloatField() loc = StringIdField() is_live = BooleanField(default=False) accuracy = IntegerField() speed = IntegerField() degrees = FloatField() comment = StringIdField() sequence = IntegerField() share_duration = IntegerField()
class MsgLoadState(BaseModel): context_loaded = BooleanField(default=False) """ Whether context was loaded (¿?). """ is_loading_around_msgs = BooleanField(default=False) """ Whether it is loading messages (¿?). """ is_loading_earlier_msgs = BooleanField(default=False) """ Whether it is loading earlier messages. """ is_loading_recent_msgs = BooleanField(default=False) """ Whether it is loading recent messages. """ no_earlier_msgs = BooleanField(default=False) """
class LocationMessage(QuotedMessageMixin, MentionsMixin, BaseMessage): """ Location message. """ __default_data__ = {'type': MessageTypes.LOCATION} body = Base64Field() lat = FloatField() lng = FloatField() loc = StringIdField() is_live = BooleanField(default=False) accuracy = IntegerField() speed = IntegerField() degrees = FloatField() comment = StringIdField() sequence = IntegerField() share_duration = IntegerField()
class MessageInfo(BaseModel): """ Message information. """ delivery = ArrayField(field_type=ModelField(model_class=MessageAck)) """ Delivery message acknowledgement list. """ delivery_remaining = IntegerField(default=0) """ Remaining delivery count. """ is_ptt = BooleanField(default=False) """ Whether it was a push to talk message. """ played = ArrayField(field_type=ModelField(model_class=MessageAck)) """ Played message acknowledgement list. """ played_remaining = IntegerField(default=0) """ Remaining played count. """ read = ArrayField(field_type=ModelField(model_class=MessageAck)) """ Read message acknowledgement list. """ read_remaining = IntegerField(default=0) """
class Presence(BaseModel): """ Presence model. """ chat_active = BooleanField() chat_state = ModelField(model_class=ChatState) chat_states = ArrayField(field_type=ModelField(model_class=ChatState), alias=['chatstates']) has_data = BooleanField() is_group = BooleanField() is_user = BooleanField() is_online = BooleanField() is_subscribed = BooleanField()
class Contact(BaseModel): name = StringIdField() """ Contact name. It will be name on phone contact list. """ formatted_name = StringIdField() """ Contact's formatted name. """ pushname = StringIdField() """ Contact defined name. It is set by contact on its whatsapp application. """ short_name = StringIdField() """ Short form of contact's name. """ type = StringIdField() """ ¿? """ userhash = StringIdField() """ ¿? """ userid = StringIdField() """ User identifier. It used to be the phone number. """ verified_level = StringIdField() """ Something about business accounts. """ verified_name = StringIdField() """ Verified contact's name for business. """ profile_pic_thumb_obj = ModelField(model_class=ProfilePicture) """ Contact picture. """ is_user = BooleanField(default=True) """ Whether contact is a user or not. """ is_business = BooleanField(default=False) """ Whether contact is a business or not. """ is_contact_blocked = BooleanField(default=False) """ Whether contact has been blocked or not. """ is_enterprise = BooleanField(default=False) """ Whether contact is an enterprise or not. """ is_high_level_verified = BooleanField(default=False) """ Whether contact is verified as enterprise or not. """ is_me = BooleanField(default=False) """ Whether contact is the current user or not. """ is_my_contact = BooleanField(default=True) """ Whether contact is in phone's contact list or not. """ is_psa = BooleanField(default=False, name='isPSA') """ ¿? """ is_verified = BooleanField(default=False) """ Whether contact is verified or not. """ is_wa_contact = BooleanField(default=True, name='isWAContact') """ Whether contact is a whatsapp user or not. """ plaintext_disabled = BooleanField(default=False) """ Whether contact has disabled plain text or not. """ status_mute = BooleanField(default=False) """ Whether contact is muted or not. """ section_header = StringIdField() """ ¿? """ labels = ArrayField(field_type=StringIdField(), default=[]) """ List of contact labels ¿? """ def to_vcard(self) -> vCard: """ Build vCard from contact. :return: vCard object of contact """ vc = vCard() o = vc.add('fn') o.value = self.formatted_name o = vc.add('tel') o.type_param = "cell" o.value = '+' + self.id[:self.id.index('@')] return vc
class Contact(BaseModel): name = StringIdField() formatted_name = StringIdField() pushname = StringIdField() short_name = StringIdField() type = StringIdField() userhash = StringIdField() userid = StringIdField() verified_level = StringIdField() verified_name = StringIdField() profile_pic_thumb_obj = ModelField(model_class=ProfilePicture) is_user = BooleanField(default=True) is_business = BooleanField(default=False) is_contact_blocked = BooleanField(default=False) is_enterprise = BooleanField(default=False) is_high_level_verified = BooleanField(default=False) is_me = BooleanField(default=False) is_my_contact = BooleanField(default=True) is_psa = BooleanField(default=False, name='isPSA') is_verified = BooleanField(default=False) is_wa_contact = BooleanField(default=True, name='isWAContact') plaintext_disabled = BooleanField(default=False) status_mute = BooleanField(default=False) section_header = StringIdField() labels = ArrayField(field_type=StringIdField(), default=[]) def to_vcard(self): vc = vCard() o = vc.add('fn') o.value = self.formatted_name o = vc.add('tel') o.type_param = "cell" o.value = '+' + self.id[:self.id.index('@')] return vc
class TextMessage(QuotedMessageMixin, LinkContentMixin, MentionsMixin, BaseMessage): text_color = StringIdField() background_color = StringIdField() font = StringIdField() contains_emoji = BooleanField(default=False)
class Conn(BaseModel): ref = StringIdField() """ Client token reference. Used on QR. """ refTTL = IntegerField() """ Ref time to live """ whatsapp_id = StringIdField(alias=['wid']) """ Whatsapp user identifier. """ connected = BooleanField() """ Whether is connected or not. """ me = StringIdField() """ Whatsapp user identifier. """ proto_version = ArrayField(field_type=IntegerField()) """ Protocol version. """ client_token = StringIdField() """ Client token. """ server_token = StringIdField() """ Server token. """ is_response = BooleanField() """ ¿? """ battery = IntegerField() """ Phone battery level, in percentage. """ plugged = BooleanField() """ Whether phone is plugged to charger or not. """ locale = StringIdField(alias=['lc']) """ Phone locale. """ language = StringIdField(alias=['lg']) """ Phone language. """ locales = StringIdField() """ Phone locale-language. """ is_24h = BooleanField(alias=['is24h']) """ Whether time must be in 24h format. """ platform = StringIdField() """ Platform (android, iphone, wp7, etc...) """ phone = ModelField(model_class=PhoneDescription) """ Phone description. """ tos = IntegerField() """ ¿? """ smb_tos = IntegerField() """ ¿? """ pushname = StringIdField() """
class Participant(BaseModel): is_admin = BooleanField(default=False) is_super_admin = BooleanField()
class MediaStreamMixin(BaseModel): streamable = BooleanField(default=False) durantion = IntegerField() is_gif = BooleanField(default=False) gif_attribution = BooleanField(default=False)
class Chat(BaseModel): """ Chat model. """ name = StringIdField() """ Chat title. """ last_message_ts = DateTimeField(alias=['t']) """ Last message timestamp. """ pin = IntegerField() """ Pin type (¿?) """ unread_count = IntegerField() """ Unread message count. """ archive = BooleanField(default=False) """ Whether chat is archived or not. """ change_number_new_jid = StringIdField() """ Information about peer's new jabber id (user identifier). It happens when a peer change its phone number. """ change_number_old_jid = StringIdField() """ Information about peer's old phone numberjabber id (user identifier). It happens when a peer change its phone number. """ contact = ModelField(model_class=Contact) """ Contact object. """ group_metadata = ModelField(model_class=GroupMetadata) """ Group metadata object. """ is_announce_grp_restrict = BooleanField(default=False) """ ¿? """ is_group = BooleanField(default=False) """ Whether chat is group or not. """ is_read_only = BooleanField(default=False) """ Whether chat is read only or not. """ kind = StringIdField() """ ¿? """ last_received_key = StringIdField() """ Last encryption key received (¿?). """ modify_tag = StringIdField() """ ¿? """ mute_expiration = IntegerField() """ Seconds to mute expiration. """ not_spam = BooleanField(default=False) """ Whether it was notified as spam chat. """ mute = ModelField(model_class=Mute) """
class DisplayInfo(BaseModel): """ Connection stream model. """ class StreamInfo(Enum): """ Stream information. """ OFFLINE = 'OFFLINE' """ Offline. """ OPENING = 'OPENING' """ Opening connection. """ PAIRING = 'PAIRING' """ Pairing phone. """ SYNCING = 'SYNCING' """ Synchronizing data. """ RESUMING = 'RESUMING' """ Resuming connection. """ CONNECTING = 'CONNECTING' """ Connecting. """ NORMAL = 'NORMAL' """ Normal. """ TIMEOUT = 'TIMEOUT' """ Connection timeout. """ class StreamMode(Enum): """ Stream mode. """ QR = 'QR' """ Wait for QR scan. """ MAIN = 'MAIN' """ Main. """ SYNCING = 'SYNCING' """ Synchronizing data. """ OFFLINE = 'OFFLINE' """ Not connected. """ CONFLICT = 'CONFLICT' """ Other browser has opened session. """ PROXYBLOCK = 'PROXYBLOCK' """ Proxy blocks connection. """ TOS_BLOCK = 'TOS_BLOCK' """ ¿? """ SMB_TOS_BLOCK = 'SMB_TOS_BLOCK' """ ¿? """ DEPRECATED_VERSION = 'DEPRECATED_VERSION' """ Using a deprecated version. """ class DisplayState(Enum): """ Display state. """ SHOW = 'SHOW' """ Display showing. """ OBSCURE = 'OBSCURE' """ Display obscured. """ HIDE = 'HIDE' """ Display hidden. """ available = BooleanField(default=False) """ Whether current user is available. """ client_expired = BooleanField() """ Whether client session has expired. """ could_force = BooleanField() """ ¿? """ display_info = EnumField(enum_class=StreamInfo) """ Stream state. """ hard_expired: BooleanField() """ ¿? """ info = EnumField(enum_class=StreamInfo) """ Same than display info? """ is_state = BooleanField() """ ¿? """ obscurity = EnumField(enum_class=DisplayState) """ Current display state. """ mode = EnumField(enum_class=StreamMode) """ Stream mode. """ phone_authed = BooleanField() """ Whether phone authorized. """ ui_active = BooleanField() """ Whether UI is active. """ resume_count = IntegerField() """
class BaseMessage(BaseModel): type = EnumField(enum_class=MessageTypes) subtype = StringIdField() body = StringIdField() timestamp = DateTimeField(name='t') notify_name = StringIdField() from_ = StringIdField(name='from') to = StringIdField() author = StringIdField() sender = StringIdField() sender_obj = ModelField(model_class=Contact) self = StringIdField(default='in') ack = EnumField(enum_class=Ack) invis = BooleanField(default=False) is_new_msg = BooleanField(default=False) star = BooleanField(default=False) is_forwarded = BooleanField(default=False) links = ArrayField(field_type=StringIdField()) chat = ModelField(model_class=Chat) is_group_msg = BooleanField(default=False) is_status_v3 = BooleanField(default=False) is_psa = BooleanField(default=False, name='isPSA') status_v3_text_bg = StringIdField() is_sent_by_me = BooleanField(default=False) is_notification = BooleanField(default=False) is_group_notification = BooleanField(default=False) is_biz_notification = BooleanField(default=False) is_media = BooleanField(default=False) is_link = BooleanField(default=False) has_link = BooleanField(default=False) is_doc = BooleanField(default=False) is_mms = BooleanField(default=False) is_revoked = BooleanField(default=False) show_forwarded = BooleanField(default=False) contains_emoji = BooleanField(default=False) is_failed = BooleanField(default=False) dir = StringIdField() rtl = BooleanField(default=False) is_persistent = BooleanField(default=False) is_user_created_type = BooleanField(default=False)
class MsgLoadState(BaseModel): context_loaded = BooleanField(default=False) is_loading_around_msgs = BooleanField(default=False) is_loading_earlier_msgs = BooleanField(default=False) is_loading_recent_msgs = BooleanField(default=False) no_earlier_msgs = BooleanField(default=False)
class Membership(BaseModel): is_admin = BooleanField(default=False)
class Stream(BaseModel): """ Connection stream model. """ class State(Enum): """ Connection states. """ OPENING = 'OPENING' """ Opening stream. """ PAIRING = 'PAIRING' """ Pairing WhatsappWeb with a phone. """ UNPAIRED = 'UNPAIRED' """ Unpaired WhatsappWeb with a phone. QR is available. """ UNPAIRED_IDLE = 'UNPAIRED_IDLE' """ Unpaired WhatsappWeb with a phone. QR is not available. """ CONNECTED = 'CONNECTED' """ WhatsappWeb is connected to a phone. """ TIMEOUT = 'TIMEOUT' """ WhatsappWeb connection to a phone is timeout. """ CONFLICT = 'CONFLICT' """ Other browser has initiated WhatsappWeb with same phone. """ UNLAUNCHED = 'UNLAUNCHED' """ WhatsappWeb application has not been launched. """ PROXYBLOCK = 'PROXYBLOCK' """ Proxy is blocking connection. """ TOS_BLOCK = 'TOS_BLOCK' """ ¿? """ SMB_TOS_BLOCK = 'SMB_TOS_BLOCK' """ ¿? """ class Stream(Enum): DISCONNECTED = 'DISCONNECTED' """ Stream disconnected. """ SYNCING = 'SYNCING' """ Synchronizing data with phone. """ RESUMING = 'RESUMING' """ Resuming connection with phone. """ CONNECTED = 'CONNECTED' """ Connected to phone. """ backoff_generation = IntegerField() """ ¿? """ can_send = BooleanField() """ Whether it is able to send messages to phone. """ has_synced = BooleanField() """ Whether it is synchronized with phone. """ is_incognito = BooleanField() """ Whether it running in a incognito tab. """ launch_generation: IntegerField() """ ¿? """ launched = BooleanField() """ Whether it has been launched. """ retry_timestamp = DateTimeField() """ ¿? """ state = EnumField(enum_class=State) """ Current stream connection state. """ stream = EnumField(enum_class=Stream) """ Current stream state """ sync_tag = StringIdField() """
class BaseMessage(BaseModel, metaclass=MessageMetaclass): """ Base message model. """ type = EnumField(enum_class=MessageTypes, read_only=True) """ Message type. """ subtype = StringIdField() """ Message subtype. """ body = StringIdField() """ Message content. """ timestamp = DateTimeField(alias=['t']) """ Message timestamp. """ notify_name = StringIdField() """ ¿? """ from_ = StringIdField(name='from') """ ¿? """ to = StringIdField() """ ¿? """ author = StringIdField() """ ¿? """ sender = StringIdField() """ Sender's contact identifier. """ sender_obj = ModelField(model_class=Contact) """ Sender's contact object. """ self = StringIdField(default='in') """ ¿? """ ack = EnumField(enum_class=Ack) """ Acknowledge state. """ invis = BooleanField(default=False) """ ¿? """ is_new_msg = BooleanField(default=False) """ Whether it is a new message or not. """ star = BooleanField(default=False) """ Whether it is starred or not. """ is_forwarded = BooleanField(default=False) """ Whether it is forwarded or not. """ links = ArrayField(field_type=StringIdField()) """ List of links of message. """ chat = ModelField(model_class=Chat) """ Chat object where message was sent. """ is_group_msg = BooleanField(default=False) """ Whether it is a group message or not. """ is_status_v3 = BooleanField(default=False) """ ¿? """ is_psa = BooleanField(default=False, name='isPSA') """ ¿? """ status_v3_text_bg = StringIdField() """ ¿? """ is_sent_by_me = BooleanField(default=False) """ Whether it is was sent by current user. """ is_notification = BooleanField(default=False) """ Whether it is a notification or not. """ is_group_notification = BooleanField(default=False) """ Whether it is a group notification or not. """ is_biz_notification = BooleanField(default=False) """ ¿? """ is_media = BooleanField(default=False) """ Whether it is a media message or not. """ is_link = BooleanField(default=False) """ Whether it is a link message or not. """ has_link = BooleanField(default=False) """ Whether message's content has links or not. """ is_doc = BooleanField(default=False) """ Whether it is a document message (pdf) or not. """ is_mms = BooleanField(default=False) """ Whether it is a multimedia message or not. """ is_revoked = BooleanField(default=False) """ Whether it is revoked (deleted?) or not. """ show_forwarded = BooleanField(default=False) """ Whether forwarded label must be shown or not. """ contains_emoji = BooleanField(default=False) """ Whether message's content contains emojis or not. """ is_failed = BooleanField(default=False) """ Whether message sending failed or not. """ dir = StringIdField() """ ¿? """ rtl = BooleanField(default=False) """ Whether message's content is a right to left text. """ is_persistent = BooleanField(default=False) """ Whether it is persistent (¿?) or not. """ is_user_created_type = BooleanField(default=False) """ Whether it is a user created type message (¿?) or not. """ has_promises = BooleanField(default=False) """