Move alltlobjects.py and fix imports

This commit is contained in:
Lonami Exo
2021-09-12 16:58:06 +02:00
parent 5fd2a017b2
commit 499fc9f603
32 changed files with 145 additions and 158 deletions

View File

@@ -5,7 +5,7 @@ import weakref
from .common import EventBuilder, EventCommon, name_inner_event
from .._misc import utils
from .. import _tl
from .._tl import custom
from ..types import _custom
_IGNORE_MAX_SIZE = 100 # len()
_IGNORE_MAX_AGE = 5 # seconds
@@ -140,12 +140,12 @@ class Album(EventBuilder):
if len(event.messages) > 1:
return super().filter(event)
class Event(EventCommon, custom.sendergetter.SenderGetter):
class Event(EventCommon, _custom.sendergetter.SenderGetter):
"""
Represents the event of a new album.
Members:
messages (Sequence[`Message <telethon.tl.custom.message.Message>`]):
messages (Sequence[`Message <telethon.tl._custom.message.Message>`]):
The list of messages belonging to the same album.
"""
def __init__(self, messages):
@@ -160,7 +160,7 @@ class Album(EventBuilder):
super().__init__(chat_peer=chat_peer,
msg_id=message.id, broadcast=bool(message.post))
custom.sendergetter.SenderGetter.__init__(self, message.sender_id)
_custom.sendergetter.SenderGetter.__init__(self, message.sender_id)
self.messages = messages
def _set_client(self, client):
@@ -217,7 +217,7 @@ class Album(EventBuilder):
@property
def forward(self):
"""
The `Forward <telethon.tl.custom.forward.Forward>`
The `Forward <telethon.tl._custom.forward.Forward>`
information for the first message in the album if it was forwarded.
"""
# Each individual message in an album all reply to the same message
@@ -229,7 +229,7 @@ class Album(EventBuilder):
async def get_reply_message(self):
"""
The `Message <telethon.tl.custom.message.Message>`
The `Message <telethon.tl._custom.message.Message>`
that this album is replying to, or `None`.
The result will be cached after its first use.

View File

@@ -4,7 +4,7 @@ import struct
from .common import EventBuilder, EventCommon, name_inner_event
from .._misc import utils
from .. import _tl
from .._tl import custom
from ..types import _custom
@name_inner_event
@@ -123,7 +123,7 @@ class CallbackQuery(EventBuilder):
return self.func(event)
return True
class Event(EventCommon, custom.sendergetter.SenderGetter):
class Event(EventCommon, _custom.sendergetter.SenderGetter):
"""
Represents the event of a new callback query.
@@ -141,7 +141,7 @@ class CallbackQuery(EventBuilder):
"""
def __init__(self, query, peer, msg_id):
super().__init__(peer, msg_id=msg_id)
custom.sendergetter.SenderGetter.__init__(self, query.user_id)
_custom.sendergetter.SenderGetter.__init__(self, query.user_id)
self.query = query
self.data_match = None
self.pattern_match = None
@@ -308,7 +308,7 @@ class CallbackQuery(EventBuilder):
.. note::
This method won't respect the previous message unlike
`Message.edit <telethon.tl.custom.message.Message.edit>`,
`Message.edit <telethon.tl._custom.message.Message.edit>`,
since the message object is normally not present.
"""
self._client.loop.create_task(self.answer())

View File

@@ -2,8 +2,9 @@ import abc
import asyncio
import warnings
from .._misc import utils
from .._tl.custom.chatgetter import ChatGetter
from .. import _tl
from .._misc import utils, tlobject
from ..types._custom.chatgetter import ChatGetter
async def _into_id_set(client, chats):
@@ -25,7 +26,7 @@ async def _into_id_set(client, chats):
utils.get_peer_id(_tl.PeerChat(chat)),
utils.get_peer_id(_tl.PeerChannel(chat)),
})
elif isinstance(chat, _tl.TLObject) and chat.SUBCLASS_OF_ID == 0x2d45687:
elif isinstance(chat, tlobject.TLObject) and chat.SUBCLASS_OF_ID == 0x2d45687:
# 0x2d45687 == crc32(b'Peer')
result.add(utils.get_peer_id(chat))
else:

View File

@@ -6,7 +6,7 @@ import asyncio
from .common import EventBuilder, EventCommon, name_inner_event
from .._misc import utils
from .. import _tl
from .._tl import custom
from ..types import _custom
@name_inner_event
@@ -74,7 +74,7 @@ class InlineQuery(EventBuilder):
return super().filter(event)
class Event(EventCommon, custom.sendergetter.SenderGetter):
class Event(EventCommon, _custom.sendergetter.SenderGetter):
"""
Represents the event of a new callback query.
@@ -91,7 +91,7 @@ class InlineQuery(EventBuilder):
"""
def __init__(self, query):
super().__init__(chat_peer=_tl.PeerUser(query.user_id))
custom.sendergetter.SenderGetter.__init__(self, query.user_id)
_custom.sendergetter.SenderGetter.__init__(self, query.user_id)
self.query = query
self.pattern_match = None
self._answered = False

View File

@@ -4,7 +4,7 @@ import functools
from .common import EventBuilder, EventCommon, name_inner_event
from .._misc import utils
from .. import _tl
from .._tl import custom
from ..types import _custom
# TODO Either the properties are poorly named or they should be
@@ -65,7 +65,7 @@ class UserUpdate(EventBuilder):
return cls.Event(update.user_id,
typing=update.action)
class Event(EventCommon, custom.sendergetter.SenderGetter):
class Event(EventCommon, _custom.sendergetter.SenderGetter):
"""
Represents the event of a user update
such as gone online, started typing, etc.
@@ -87,7 +87,7 @@ class UserUpdate(EventBuilder):
"""
def __init__(self, peer, *, status=None, chat_peer=None, typing=None):
super().__init__(chat_peer or peer)
custom.sendergetter.SenderGetter.__init__(self, utils.get_peer_id(peer))
_custom.sendergetter.SenderGetter.__init__(self, utils.get_peer_id(peer))
self.status = status
self.action = typing