Add PyrogramType · stack-queue/pyrogram@6ab1c87 · GitHub
Skip to content

Commit 6ab1c87

Browse files
committed
Add PyrogramType
1 parent 5ecbfbf commit 6ab1c87

21 files changed

Lines changed: 87 additions & 78 deletions

pyrogram/client/types/messages_and_media/animation.py

Lines changed: 2 additions & 4 deletions

pyrogram/client/types/messages_and_media/audio.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
from struct import pack
2020

2121
from pyrogram.api import types
22-
from pyrogram.api.core import Object
2322
from .photo_size import PhotoSize
23+
from ..pyrogram_type import PyrogramType
2424
from ...ext.utils import encode
2525

2626

27-
class Audio(Object):
27+
class Audio(PyrogramType):
2828
"""This object represents an audio file to be treated as music by the Telegram clients.
2929
3030
Args:
@@ -56,8 +56,6 @@ class Audio(Object):
5656
Title of the audio as defined by sender or by audio tags.
5757
"""
5858

59-
ID = 0xb0700006
60-
6159
def __init__(self, file_id: str, duration: int, *,
6260
thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None,
6361
performer: str = None, title: str = None,

pyrogram/client/types/messages_and_media/contact.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from pyrogram.api import types
20-
from pyrogram.api.core import Object
20+
from ..pyrogram_type import PyrogramType
2121

2222

23-
class Contact(Object):
23+
class Contact(PyrogramType):
2424
"""This object represents a phone contact.
2525
2626
Args:
@@ -40,8 +40,6 @@ class Contact(Object):
4040
Additional data about the contact in the form of a vCard.
4141
"""
4242

43-
ID = 0xb0700011
44-
4543
def __init__(self, phone_number: str, first_name: str, *,
4644
last_name: str = None, user_id: int = None, vcard: str = None,
4745
client=None, raw=None):

pyrogram/client/types/messages_and_media/document.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
from struct import pack
2020

2121
from pyrogram.api import types
22-
from pyrogram.api.core import Object
2322
from .photo_size import PhotoSize
23+
from ..pyrogram_type import PyrogramType
2424
from ...ext.utils import encode
2525

2626

27-
class Document(Object):
27+
class Document(PyrogramType):
2828
"""This object represents a general file (as opposed to photos, voice messages, audio files, ...).
2929
3030
Args:
@@ -47,8 +47,6 @@ class Document(Object):
4747
Date the document was sent in Unix time.
4848
"""
4949

50-
ID = 0xb0700007
51-
5250
def __init__(self, file_id: str, *,
5351
thumb=None, file_name: str = None, mime_type: str = None, file_size: int = None, date: int = None,
5452
client=None, raw=None):

pyrogram/client/types/messages_and_media/location.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from pyrogram.api import types
20-
from pyrogram.api.core import Object
20+
from ..pyrogram_type import PyrogramType
2121

2222

23-
class Location(Object):
23+
class Location(PyrogramType):
2424
"""This object represents a point on the map.
2525
2626
Args:
@@ -31,8 +31,6 @@ class Location(Object):
3131
Latitude as defined by sender.
3232
"""
3333

34-
ID = 0xb0700012
35-
3634
def __init__(self, longitude: float, latitude: float, *,
3735
client=None, raw=None):
3836
self.longitude = longitude

pyrogram/client/types/messages_and_media/message.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@
1818

1919
import pyrogram
2020
from pyrogram.api import types, functions
21-
from pyrogram.api.core import Object
2221
from pyrogram.api.errors import MessageIdsEmpty, StickersetInvalid
2322
from .contact import Contact
2423
from .location import Location
2524
from .message_entity import MessageEntity
2625
from ..messages_and_media.photo import Photo
26+
from ..pyrogram_type import PyrogramType
2727
from ..user_and_chats.chat import Chat
2828
from ..user_and_chats.user import User
2929
from ...ext.utils import Str
3030

3131

32-
class Message(Object):
32+
class Message(PyrogramType):
3333
"""This object represents a message.
3434
3535
Args:
@@ -224,7 +224,6 @@ class Message(Object):
224224
"""
225225

226226
# TODO: Add game missing field. Also invoice, successful_payment, connected_website
227-
ID = 0xb0700003
228227

229228
def __init__(self, message_id: int, *,
230229
date: int = None, chat=None, from_user=None, forward_from=None, forward_from_chat=None,
@@ -461,7 +460,7 @@ def parse(client, message: types.Message or types.MessageService or types.Messag
461460
set_name = None
462461

463462
sticker = pyrogram.Sticker.parse(client, doc, image_size_attributes,
464-
set_name, sticker_attribute, file_name)
463+
set_name, sticker_attribute, file_name)
465464
else:
466465
document = pyrogram.Document.parse(client, doc, file_name)
467466
elif isinstance(media, types.MessageMediaWebPage):

pyrogram/client/types/messages_and_media/message_entity.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

1919
from pyrogram.api import types
20-
from pyrogram.api.core import Object
20+
from ..pyrogram_type import PyrogramType
2121
from ..user_and_chats.user import User
2222

2323

24-
class MessageEntity(Object):
24+
class MessageEntity(PyrogramType):
2525
"""This object represents one special entity in a text message.
2626
For example, hashtags, usernames, URLs, etc.
2727
@@ -45,8 +45,6 @@ class MessageEntity(Object):
4545
For "text_mention" only, the mentioned user.
4646
"""
4747

48-
ID = 0xb0700004
49-
5048
ENTITIES = {
5149
types.MessageEntityMention.ID: "mention",
5250
types.MessageEntityHashtag.ID: "hashtag",

pyrogram/client/types/messages_and_media/messages.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
from pyrogram.api.core import Object
19+
from ..pyrogram_type import PyrogramType
2020

2121

22-
class Messages(Object):
22+
class Messages(PyrogramType):
2323
"""This object represents a chat's messages.
2424
2525
Args:
@@ -30,8 +30,6 @@ class Messages(Object):
3030
Requested messages.
3131
"""
3232

33-
ID = 0xb0700026
34-
3533
def __init__(self, total_count: int, messages: list):
3634
self.total_count = total_count
3735
self.messages = messages

pyrogram/client/types/messages_and_media/photo.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
from struct import pack
2121

2222
from pyrogram.api import types
23-
from pyrogram.api.core import Object
2423
from .photo_size import PhotoSize
24+
from ..pyrogram_type import PyrogramType
2525
from ...ext.utils import encode
2626

2727

28-
class Photo(Object):
28+
class Photo(PyrogramType):
2929
"""This object represents a Photo.
3030
3131
Args:
@@ -39,8 +39,6 @@ class Photo(Object):
3939
Available sizes of this photo.
4040
"""
4141

42-
ID = 0xb0700027
43-
4442
def __init__(self, id: str, date: int, sizes: list, *,
4543
client=None, raw=None):
4644
self.id = id

pyrogram/client/types/messages_and_media/photo_size.py

Lines changed: 2 additions & 4 deletions

0 commit comments

Comments
 (0)