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 MultiVCardMessage(QuotedMessageMixin, MentionsMixin, BaseMessage): """ Multi vCard message. """ __default_data__ = {'type': MessageTypes.MULTI_VCARD} vcard_list = ArrayField(field_type=ModelField(model_class=VCardItem))
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 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 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 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 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 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 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() 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 MentionsMixin(BaseModel): mentioned_jid_list = ArrayField(field_type=StringIdField()) """
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 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))