Esempio n. 1
0
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()
Esempio n. 2
0
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())
    """
Esempio n. 3
0
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())
Esempio n. 4
0
class StickerPack(BaseModel):
    name = StringIdField()
    """
    Sticker pack name.
    """

    url = StringIdField()
    """
Esempio n. 5
0
class NotificationMessage(BaseMessage):
    # group notifications
    recipients = ArrayField(field_type=StringIdField())
    broadcast = BooleanField(default=False)
    multicast = BooleanField(default=False)

    url_text = StringIdField()
    url_number = IntegerField()
Esempio n. 6
0
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())
Esempio n. 7
0
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()
Esempio n. 8
0
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)
Esempio n. 9
0
class VCardItem(BaseModel):
    """
    vCard item.
    """

    display_name = StringIdField()
    """
    Contact's name.
    """

    vcard = StringIdField()
    """
Esempio n. 10
0
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()
Esempio n. 11
0
class ProfilePicture(BaseModel):
    eurl = StringIdField()
    """
    Url to contact picture.
    """

    raw = StringIdField()
    """
    ¿?
    """

    tag = StringIdField()
    """
Esempio n. 12
0
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()
Esempio n. 13
0
class BaseModel(DirtyBaseModel, metaclass=CamelCaseMeta):
    """
    Base model which convert field name from underscore-style to camelCase-style automatically.
    """

    #: Unique identifier.
    id = StringIdField(read_only=True)
Esempio n. 14
0
class PhoneDescription(BaseModel):
    whatsapp_version = StringIdField(alias=['wa_version'])
    """
    Whatsapp version running on phone.
    """

    mcc = StringIdField()
    """
    ¿?
    """

    mnc = StringIdField()
    """
    ¿?
    """

    os_version = StringIdField()
    """
    Operating system version running on phone.
    """

    device_manufacturer = StringIdField()
    """
    Phone manufacturer.
    """

    device_model = StringIdField()
    """
    Phone model.
    """

    os_build_number = StringIdField()
    """
Esempio n. 15
0
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()
    """
Esempio n. 16
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()
    """
Esempio n. 17
0
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()
Esempio n. 18
0
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)
Esempio n. 19
0
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)
Esempio n. 20
0
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()
    """
Esempio n. 21
0
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()
Esempio n. 22
0
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)
Esempio n. 23
0
class MentionsMixin(BaseModel):
    mentioned_jid_list = ArrayField(field_type=StringIdField())
    """
Esempio n. 24
0
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()
    """
Esempio n. 25
0
class AuthorMixin(BaseModel):
    author = StringIdField()
Esempio n. 26
0
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)
    """
Esempio n. 27
0
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
Esempio n. 28
0
class ProfilePicture(BaseModel):
    id = StringIdField()
    eurl = StringIdField()
    raw = StringIdField()
    tag = StringIdField()
Esempio n. 29
0
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
Esempio n. 30
0
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()
    """