mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 16:24:15 +03:00
Handle UpdateShortSentMessage in send_message
This commit is contained in:
parent
816f6012a9
commit
6be93c69ed
|
@ -49,13 +49,13 @@ async def send_message(
|
||||||
link_preview: Optional[bool] = None,
|
link_preview: Optional[bool] = None,
|
||||||
reply_to: Optional[int] = None,
|
reply_to: Optional[int] = None,
|
||||||
) -> Message:
|
) -> Message:
|
||||||
peer = (await self._resolve_to_packed(chat))._to_input_peer()
|
packed = await self._resolve_to_packed(chat)
|
||||||
|
peer = packed._to_input_peer()
|
||||||
message, entities = parse_message(
|
message, entities = parse_message(
|
||||||
text=text, markdown=markdown, html=html, allow_empty=False
|
text=text, markdown=markdown, html=html, allow_empty=False
|
||||||
)
|
)
|
||||||
random_id = generate_random_id()
|
random_id = generate_random_id()
|
||||||
return self._build_message_map(
|
result = await self(
|
||||||
await self(
|
|
||||||
functions.messages.send_message(
|
functions.messages.send_message(
|
||||||
no_webpage=not link_preview,
|
no_webpage=not link_preview,
|
||||||
silent=False,
|
silent=False,
|
||||||
|
@ -97,9 +97,56 @@ async def send_message(
|
||||||
schedule_date=None,
|
schedule_date=None,
|
||||||
send_as=None,
|
send_as=None,
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
if isinstance(result, types.UpdateShortSentMessage):
|
||||||
|
return Message._from_raw(
|
||||||
|
self,
|
||||||
|
types.Message(
|
||||||
|
out=result.out,
|
||||||
|
mentioned=False,
|
||||||
|
media_unread=False,
|
||||||
|
silent=False,
|
||||||
|
post=False,
|
||||||
|
from_scheduled=False,
|
||||||
|
legacy=False,
|
||||||
|
edit_hide=False,
|
||||||
|
pinned=False,
|
||||||
|
noforwards=False,
|
||||||
|
id=result.id,
|
||||||
|
from_id=types.PeerUser(user_id=self._session.user.id)
|
||||||
|
if self._session.user
|
||||||
|
else None,
|
||||||
|
peer_id=packed._to_peer(),
|
||||||
|
fwd_from=None,
|
||||||
|
via_bot_id=None,
|
||||||
|
reply_to=types.MessageReplyHeader(
|
||||||
|
reply_to_scheduled=False,
|
||||||
|
forum_topic=False,
|
||||||
|
reply_to_msg_id=reply_to,
|
||||||
|
reply_to_peer_id=None,
|
||||||
|
reply_to_top_id=None,
|
||||||
|
)
|
||||||
|
if reply_to
|
||||||
|
else None,
|
||||||
|
date=result.date,
|
||||||
|
message=message if isinstance(message, str) else (message.text or ""),
|
||||||
|
media=result.media,
|
||||||
|
reply_markup=None,
|
||||||
|
entities=result.entities,
|
||||||
|
views=None,
|
||||||
|
forwards=None,
|
||||||
|
replies=None,
|
||||||
|
edit_date=None,
|
||||||
|
post_author=None,
|
||||||
|
grouped_id=None,
|
||||||
|
reactions=None,
|
||||||
|
restriction_reason=None,
|
||||||
|
ttl_period=result.ttl_period,
|
||||||
),
|
),
|
||||||
peer,
|
{},
|
||||||
).with_random_id(random_id)
|
)
|
||||||
|
else:
|
||||||
|
return self._build_message_map(result, peer).with_random_id(random_id)
|
||||||
|
|
||||||
|
|
||||||
async def edit_message(
|
async def edit_message(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user