示例#1
0
 def read(data: BytesIO, *args: Any) -> "InputMediaUploadedDocument":
     flags = Int.read(data)
     
     nosound_video = True if flags & (1 << 3) else False
     force_file = True if flags & (1 << 4) else False
     file = TLObject.read(data)
     
     thumb = TLObject.read(data) if flags & (1 << 2) else None
     
     mime_type = String.read(data)
     
     attributes = TLObject.read(data)
     
     stickers = TLObject.read(data) if flags & (1 << 0) else []
     
     ttl_seconds = Int.read(data) if flags & (1 << 1) else None
     return InputMediaUploadedDocument(file=file, mime_type=mime_type, attributes=attributes, nosound_video=nosound_video, force_file=force_file, thumb=thumb, stickers=stickers, ttl_seconds=ttl_seconds)
示例#2
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 1) if self.mask else 0
        flags |= (1 << 0) if self.mask_coords is not None else 0
        data.write(Int(flags))

        data.write(String(self.alt))

        data.write(self.stickerset.write())

        if self.mask_coords is not None:
            data.write(self.mask_coords.write())

        return data.getvalue()
示例#3
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags

        data.write(String(self.type))

        data.write(self.location.write())

        data.write(Int(self.w))

        data.write(Int(self.h))

        data.write(Bytes(self.bytes))

        return data.getvalue()
示例#4
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.dark else 0
        flags |= (1 << 1) if self.format is not None else 0
        flags |= (1 << 1) if self.theme is not None else 0
        data.write(Int(flags))

        if self.format is not None:
            data.write(String(self.format))

        if self.theme is not None:
            data.write(self.theme.write())

        return data.getvalue()
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        # No flags
        
        data.write(self.peer.write())
        
        data.write(String(self.link))
        
        data.write(Int(self.offset_date))
        
        data.write(self.offset_user.write())
        
        data.write(Int(self.limit))
        
        return data.getvalue()
    def read(data: BytesIO, *args: Any) -> "UpdateShortChatMessage":
        flags = Int.read(data)

        out = True if flags & (1 << 1) else False
        mentioned = True if flags & (1 << 4) else False
        media_unread = True if flags & (1 << 5) else False
        silent = True if flags & (1 << 13) else False
        id = Int.read(data)

        from_id = Int.read(data)

        chat_id = Int.read(data)

        message = String.read(data)

        pts = Int.read(data)

        pts_count = Int.read(data)

        date = Int.read(data)

        fwd_from = TLObject.read(data) if flags & (1 << 2) else None

        via_bot_id = Int.read(data) if flags & (1 << 11) else None
        reply_to = TLObject.read(data) if flags & (1 << 3) else None

        entities = TLObject.read(data) if flags & (1 << 7) else []

        ttl_period = Int.read(data) if flags & (1 << 25) else None
        return UpdateShortChatMessage(id=id,
                                      from_id=from_id,
                                      chat_id=chat_id,
                                      message=message,
                                      pts=pts,
                                      pts_count=pts_count,
                                      date=date,
                                      out=out,
                                      mentioned=mentioned,
                                      media_unread=media_unread,
                                      silent=silent,
                                      fwd_from=fwd_from,
                                      via_bot_id=via_bot_id,
                                      reply_to=reply_to,
                                      entities=entities,
                                      ttl_period=ttl_period)
示例#7
0
    def read(data: BytesIO, *args: Any) -> "WebFile":
        # No flags

        size = Int.read(data)

        mime_type = String.read(data)

        file_type = TLObject.read(data)

        mtime = Int.read(data)

        bytes = Bytes.read(data)

        return WebFile(size=size,
                       mime_type=mime_type,
                       file_type=file_type,
                       mtime=mtime,
                       bytes=bytes)
示例#8
0
    def read(data: BytesIO, *args: Any) -> "PhotoCachedSize":
        # No flags

        type = String.read(data)

        location = TLObject.read(data)

        w = Int.read(data)

        h = Int.read(data)

        bytes = Bytes.read(data)

        return PhotoCachedSize(type=type,
                               location=location,
                               w=w,
                               h=h,
                               bytes=bytes)
示例#9
0
 def read(data: BytesIO, *args: Any) -> "GetAdminLog":
     flags = Int.read(data)
     
     channel = TLObject.read(data)
     
     q = String.read(data)
     
     events_filter = TLObject.read(data) if flags & (1 << 0) else None
     
     admins = TLObject.read(data) if flags & (1 << 1) else []
     
     max_id = Long.read(data)
     
     min_id = Long.read(data)
     
     limit = Int.read(data)
     
     return GetAdminLog(channel=channel, q=q, max_id=max_id, min_id=min_id, limit=limit, events_filter=events_filter, admins=admins)
    def read(data: BytesIO, *args: Any) -> "GetExportedChatInvites":
        flags = Int.read(data)

        revoked = True if flags & (1 << 3) else False
        peer = TLObject.read(data)

        admin_id = TLObject.read(data)

        offset_date = Int.read(data) if flags & (1 << 2) else None
        offset_link = String.read(data) if flags & (1 << 2) else None
        limit = Int.read(data)

        return GetExportedChatInvites(peer=peer,
                                      admin_id=admin_id,
                                      limit=limit,
                                      revoked=revoked,
                                      offset_date=offset_date,
                                      offset_link=offset_link)
示例#11
0
 def read(data: BytesIO, *args: Any) -> "WallPaper":
     
     id = Long.read(data)
     flags = Int.read(data)
     
     creator = True if flags & (1 << 0) else False
     default = True if flags & (1 << 1) else False
     pattern = True if flags & (1 << 3) else False
     dark = True if flags & (1 << 4) else False
     access_hash = Long.read(data)
     
     slug = String.read(data)
     
     document = TLObject.read(data)
     
     settings = TLObject.read(data) if flags & (1 << 2) else None
     
     return WallPaper(id=id, access_hash=access_hash, slug=slug, document=document, creator=creator, default=default, pattern=pattern, dark=dark, settings=settings)
示例#12
0
    def read(data: BytesIO, *args: Any) -> "GroupCall":
        # No flags

        call = TLObject.read(data)

        participants = TLObject.read(data)

        participants_next_offset = String.read(data)

        chats = TLObject.read(data)

        users = TLObject.read(data)

        return GroupCall(call=call,
                         participants=participants,
                         participants_next_offset=participants_next_offset,
                         chats=chats,
                         users=users)
示例#13
0
    def read(data: BytesIO, *args: Any) -> "Folder":
        flags = Int.read(data)

        autofill_new_broadcasts = True if flags & (1 << 0) else False
        autofill_public_groups = True if flags & (1 << 1) else False
        autofill_new_correspondents = True if flags & (1 << 2) else False
        id = Int.read(data)

        title = String.read(data)

        photo = TLObject.read(data) if flags & (1 << 3) else None

        return Folder(id=id,
                      title=title,
                      autofill_new_broadcasts=autofill_new_broadcasts,
                      autofill_public_groups=autofill_public_groups,
                      autofill_new_correspondents=autofill_new_correspondents,
                      photo=photo)
示例#14
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.ttl_seconds is not None else 0
        flags |= (1 << 1) if self.query is not None else 0
        data.write(Int(flags))

        data.write(self.id.write())

        if self.ttl_seconds is not None:
            data.write(Int(self.ttl_seconds))

        if self.query is not None:
            data.write(String(self.query))

        return data.getvalue()
 def read(data: BytesIO, *args: Any) -> "SendInlineBotResult":
     flags = Int.read(data)
     
     silent = True if flags & (1 << 5) else False
     background = True if flags & (1 << 6) else False
     clear_draft = True if flags & (1 << 7) else False
     hide_via = True if flags & (1 << 11) else False
     peer = TLObject.read(data)
     
     reply_to_msg_id = Int.read(data) if flags & (1 << 0) else None
     random_id = Long.read(data)
     
     query_id = Long.read(data)
     
     id = String.read(data)
     
     schedule_date = Int.read(data) if flags & (1 << 10) else None
     return SendInlineBotResult(peer=peer, random_id=random_id, query_id=query_id, id=id, silent=silent, background=background, clear_draft=clear_draft, hide_via=hide_via, reply_to_msg_id=reply_to_msg_id, schedule_date=schedule_date)
    def read(data: BytesIO, *args: Any) -> "PollResults":
        flags = Int.read(data)

        min = True if flags & (1 << 0) else False
        results = TLObject.read(data) if flags & (1 << 1) else []

        total_voters = Int.read(data) if flags & (1 << 2) else None
        recent_voters = TLObject.read(data, Int) if flags & (1 << 3) else []

        solution = String.read(data) if flags & (1 << 4) else None
        solution_entities = TLObject.read(data) if flags & (1 << 4) else []

        return PollResults(min=min,
                           results=results,
                           total_voters=total_voters,
                           recent_voters=recent_voters,
                           solution=solution,
                           solution_entities=solution_entities)
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 1) if self.entities is not None else 0
        flags |= (1 << 2) if self.reply_markup is not None else 0
        data.write(Int(flags))

        data.write(String(self.message))

        if self.entities is not None:
            data.write(Vector(self.entities))

        if self.reply_markup is not None:
            data.write(self.reply_markup.write())

        return data.getvalue()
示例#18
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.next_offset is not None else 0
        data.write(Int(flags))

        data.write(Int(self.count))

        data.write(Vector(self.votes))

        data.write(Vector(self.users))

        if self.next_offset is not None:
            data.write(String(self.next_offset))

        return data.getvalue()
    def read(data: BytesIO, *args: Any) -> "PhotoSizeProgressive":
        # No flags

        type = String.read(data)

        location = TLObject.read(data)

        w = Int.read(data)

        h = Int.read(data)

        sizes = TLObject.read(data, Int)

        return PhotoSizeProgressive(type=type,
                                    location=location,
                                    w=w,
                                    h=h,
                                    sizes=sizes)
示例#20
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.error is not None else 0
        flags |= (1 << 1) if self.shipping_options is not None else 0
        data.write(Int(flags))

        data.write(Long(self.query_id))

        if self.error is not None:
            data.write(String(self.error))

        if self.shipping_options is not None:
            data.write(Vector(self.shipping_options))

        return data.getvalue()
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.entities is not None else 0
        data.write(Int(flags))

        data.write(self.media.write())

        data.write(Long(self.random_id))

        data.write(String(self.message))

        if self.entities is not None:
            data.write(Vector(self.entities))

        return data.getvalue()
    def read(data: BytesIO, *args: Any) -> "GroupParticipants":
        # No flags

        count = Int.read(data)

        participants = TLObject.read(data)

        next_offset = String.read(data)

        users = TLObject.read(data)

        version = Int.read(data)

        return GroupParticipants(count=count,
                                 participants=participants,
                                 next_offset=next_offset,
                                 users=users,
                                 version=version)
示例#23
0
    def read(data: BytesIO, *args: Any) -> "ChannelForbidden":
        flags = Int.read(data)

        broadcast = True if flags & (1 << 5) else False
        megagroup = True if flags & (1 << 8) else False
        id = Int.read(data)

        access_hash = Long.read(data)

        title = String.read(data)

        until_date = Int.read(data) if flags & (1 << 16) else None
        return ChannelForbidden(id=id,
                                access_hash=access_hash,
                                title=title,
                                broadcast=broadcast,
                                megagroup=megagroup,
                                until_date=until_date)
示例#24
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.prefixes is not None else 0
        flags |= (1 << 1) if self.patterns is not None else 0
        data.write(Int(flags))

        data.write(String(self.country_code))

        if self.prefixes is not None:
            data.write(Vector(self.prefixes, String))

        if self.patterns is not None:
            data.write(Vector(self.patterns, String))

        return data.getvalue()
示例#25
0
    def read(data: BytesIO, *args: Any) -> "InputSecureFileUploaded":
        # No flags

        id = Long.read(data)

        parts = Int.read(data)

        md5_checksum = String.read(data)

        file_hash = Bytes.read(data)

        secret = Bytes.read(data)

        return InputSecureFileUploaded(id=id,
                                       parts=parts,
                                       md5_checksum=md5_checksum,
                                       file_hash=file_hash,
                                       secret=secret)
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 1) if self.out else 0
        flags |= (1 << 4) if self.mentioned else 0
        flags |= (1 << 5) if self.media_unread else 0
        flags |= (1 << 13) if self.silent else 0
        flags |= (1 << 2) if self.fwd_from is not None else 0
        flags |= (1 << 11) if self.via_bot_id is not None else 0
        flags |= (1 << 3) if self.reply_to is not None else 0
        flags |= (1 << 7) if self.entities is not None else 0
        flags |= (1 << 25) if self.ttl_period is not None else 0
        data.write(Int(flags))
        
        data.write(Int(self.id))
        
        data.write(Int(self.user_id))
        
        data.write(String(self.message))
        
        data.write(Int(self.pts))
        
        data.write(Int(self.pts_count))
        
        data.write(Int(self.date))
        
        if self.fwd_from is not None:
            data.write(self.fwd_from.write())
        
        if self.via_bot_id is not None:
            data.write(Int(self.via_bot_id))
        
        if self.reply_to is not None:
            data.write(self.reply_to.write())
        
        if self.entities is not None:
            data.write(Vector(self.entities))
        
        if self.ttl_period is not None:
            data.write(Int(self.ttl_period))
        
        return data.getvalue()
示例#27
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.autofill_new_broadcasts else 0
        flags |= (1 << 1) if self.autofill_public_groups else 0
        flags |= (1 << 2) if self.autofill_new_correspondents else 0
        flags |= (1 << 3) if self.photo is not None else 0
        data.write(Int(flags))

        data.write(Int(self.id))

        data.write(String(self.title))

        if self.photo is not None:
            data.write(self.photo.write())

        return data.getvalue()
示例#28
0
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.no_muted is not None else 0
        data.write(Int(flags))

        data.write(Int(self.token_type))

        data.write(String(self.token))

        data.write(Bool(self.app_sandbox))

        data.write(Bytes(self.secret))

        data.write(Vector(self.other_uids, Int))

        return data.getvalue()
示例#29
0
    def read(data: BytesIO, *args: Any) -> "EditInlineBotMessage":
        flags = Int.read(data)

        no_webpage = True if flags & (1 << 1) else False
        id = TLObject.read(data)

        message = String.read(data) if flags & (1 << 11) else None
        media = TLObject.read(data) if flags & (1 << 14) else None

        reply_markup = TLObject.read(data) if flags & (1 << 2) else None

        entities = TLObject.read(data) if flags & (1 << 3) else []

        return EditInlineBotMessage(id=id,
                                    no_webpage=no_webpage,
                                    message=message,
                                    media=media,
                                    reply_markup=reply_markup,
                                    entities=entities)
    def write(self) -> bytes:
        data = BytesIO()
        data.write(Int(self.ID, False))

        flags = 0
        flags |= (1 << 0) if self.popup else 0
        flags |= (1 << 1) if self.min_age_confirm is not None else 0
        data.write(Int(flags))

        data.write(self.id.write())

        data.write(String(self.text))

        data.write(Vector(self.entities))

        if self.min_age_confirm is not None:
            data.write(Int(self.min_age_confirm))

        return data.getvalue()