class Participant(BaseModel): """ Live location participant model. """ accuracy = IntegerField() """ Location accuracy in meters. """ comment = StringIdField() """ Comment sent with live location message. """ degrees = FloatField() """ User direction in degrees. """ expiration = DateTimeField() """ When live location will expire. """ last_update = DateTimeField() """ Last update timestamp. """ lat = FloatField() """ Latitude. """ lng = FloatField() """ Longitude. """ msg = ModelField(model_class=BaseMessage) """ Message used to start live location. """ contact = ModelField(model_class=Contact) """ Live location owner. """ sequence = IntegerField() """ Sequence number. """ speed = 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 StatusV3(BaseModel): """ StatusV3 model """ unread_count = IntegerField() """ Unread statuses """ expire_ts = DateTimeField() """ Status expiration date """ contact = ModelField(model_class=Contact) """ Contact object """ last_received_key = StringIdField() """ Last encryption key received (¿?). """ read_keys = HashMapField(field_type=StringIdField())
class MultiVCardMessage(QuotedMessageMixin, MentionsMixin, BaseMessage): """ Multi vCard message. """ __default_data__ = {'type': MessageTypes.MULTI_VCARD} vcard_list = ArrayField(field_type=ModelField(model_class=VCardItem))
class GroupMetadata(BaseModel): announce = StringIdField() creation = DateTimeField() desc = StringField() desc_owner = StringIdField() desc_time = DateTimeField() owner = StringIdField() participants = ArrayField(field_type=ModelField(model_class=Membership)) restrict = StringIdField()
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 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 LiveLocation(BaseModel): """ Live location model. """ duration = TimedeltaField() """ Live location duration. """ participants = ArrayField(field_type=ModelField(model_class=Participant)) """
class GroupMetadata(BaseModel): """ Group metadata model. """ announce = StringIdField() """ ¿? """ creation = DateTimeField() """ Group creation timestamp. """ desc = StringField() """ Group description. """ desc_owner = StringIdField() """ Who change last group description. """ desc_time = DateTimeField() """ When last group description was changed. """ owner = StringIdField() """ Who made group. """ participants = ArrayField(field_type=ModelField(model_class=Participant)) """ List of participants. """ restrict = StringIdField() """ ¿? """ group_invite_link = StringIdField() """ Group link to invite people. """ invite_code = StringIdField() """
class GroupMetadata(BaseModel): announce = StringIdField() creation = DateTimeField() desc = StringField() desc_owner = StringIdField() desc_time = DateTimeField() owner = StringIdField() participants = ArrayField(field_type=ModelField(model_class=Participant)) restrict = StringIdField() group_invite_link = StringIdField() invite_code = StringIdField()
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 QuotedMessageMixin(BaseModel): quoted_msg_obj = ModelField(model_class=BaseMessage) """ Original message object quoted. """ quoted_stanza_id = StringIdField(name='quotedStanzaID') """ Original message identifier quoted. """ quoted_participant = StringIdField() """ Sender identifier. """ quoted_remote_jid = StringIdField() """
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 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) """
class MultiVCardMessage(QuotedMessageMixin, MentionsMixin, BaseMessage): vcard_list = ArrayField(field_type=ModelField(model_class=VCardItem))
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 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 QuotedMessageMixin(BaseModel): quoted_msg_obj = ModelField() quoted_stanza_id = StringIdField(name='quotedStanzaID') quoted_participant = StringIdField() quoted_remote_jid = StringIdField()
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) """