mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-21 21:39:46 +03:00
allow sending in topic forums
This commit is contained in:
parent
83f13da420
commit
10c46be72f
|
@ -634,6 +634,7 @@ class MessageMethods:
|
|||
file: 'typing.Union[hints.FileLike, typing.Sequence[hints.FileLike]]' = None,
|
||||
thumb: 'hints.FileLike' = None,
|
||||
force_document: bool = False,
|
||||
topic_id: int = None,
|
||||
clear_draft: bool = False,
|
||||
buttons: typing.Optional['hints.MarkupLike'] = None,
|
||||
silent: bool = None,
|
||||
|
@ -675,6 +676,9 @@ class MessageMethods:
|
|||
Whether to reply to a message or not. If an integer is provided,
|
||||
it should be the ID of the message that it should reply to.
|
||||
|
||||
topic_id (`int`, optional):
|
||||
Whether to send message in topic forum, It should be ID of topic forum.
|
||||
|
||||
attributes (`list`, optional):
|
||||
Optional attributes that override the inferred ones, like
|
||||
:tl:`DocumentAttributeFilename` and so on.
|
||||
|
@ -821,7 +825,8 @@ class MessageMethods:
|
|||
buttons=buttons, clear_draft=clear_draft, silent=silent,
|
||||
schedule=schedule, supports_streaming=supports_streaming,
|
||||
formatting_entities=formatting_entities,
|
||||
comment_to=comment_to, background=background
|
||||
comment_to=comment_to, background=background,
|
||||
topic_id=topic_id
|
||||
)
|
||||
|
||||
entity = await self.get_input_entity(entity)
|
||||
|
@ -846,6 +851,7 @@ class MessageMethods:
|
|||
silent=silent,
|
||||
background=background,
|
||||
reply_to=reply_to,
|
||||
topic_id=topic_id,
|
||||
buttons=markup,
|
||||
formatting_entities=message.entities,
|
||||
parse_mode=None, # explicitly disable parse_mode to force using even empty formatting_entities
|
||||
|
@ -856,6 +862,7 @@ class MessageMethods:
|
|||
peer=entity,
|
||||
message=message.message or '',
|
||||
silent=silent,
|
||||
top_msg_id=topic_id,
|
||||
background=background,
|
||||
reply_to_msg_id=utils.get_message_id(reply_to),
|
||||
reply_markup=markup,
|
||||
|
@ -878,6 +885,7 @@ class MessageMethods:
|
|||
peer=entity,
|
||||
message=message,
|
||||
entities=formatting_entities,
|
||||
top_msg_id=topic_id,
|
||||
no_webpage=not link_preview,
|
||||
reply_to_msg_id=utils.get_message_id(reply_to),
|
||||
clear_draft=clear_draft,
|
||||
|
@ -912,6 +920,7 @@ class MessageMethods:
|
|||
messages: 'typing.Union[hints.MessageIDLike, typing.Sequence[hints.MessageIDLike]]',
|
||||
from_peer: 'hints.EntityLike' = None,
|
||||
*,
|
||||
topic_id: int = None,
|
||||
background: bool = None,
|
||||
with_my_score: bool = None,
|
||||
silent: bool = None,
|
||||
|
@ -940,6 +949,9 @@ class MessageMethods:
|
|||
order for the forward to work. This parameter indicates
|
||||
the entity from which the messages should be forwarded.
|
||||
|
||||
topic_id (`int`, optional):
|
||||
Whether to forward message in topic forum, It should be ID of topic forum.
|
||||
|
||||
silent (`bool`, optional):
|
||||
Whether the message should notify people with sound or not.
|
||||
Defaults to `False` (send with a notification sound unless
|
||||
|
@ -1025,6 +1037,7 @@ class MessageMethods:
|
|||
from_peer=chat,
|
||||
id=chunk,
|
||||
to_peer=entity,
|
||||
top_msg_id=topic_id,
|
||||
silent=silent,
|
||||
background=background,
|
||||
with_my_score=with_my_score,
|
||||
|
|
|
@ -101,6 +101,7 @@ class UploadMethods:
|
|||
force_document: bool = False,
|
||||
file_size: int = None,
|
||||
clear_draft: bool = False,
|
||||
topic_id: int = None,
|
||||
progress_callback: 'hints.ProgressCallback' = None,
|
||||
reply_to: 'hints.MessageIDLike' = None,
|
||||
attributes: 'typing.Sequence[types.TypeDocumentAttribute]' = None,
|
||||
|
@ -201,6 +202,9 @@ class UploadMethods:
|
|||
reply_to (`int` | `Message <telethon.tl.custom.message.Message>`):
|
||||
Same as `reply_to` from `send_message`.
|
||||
|
||||
topic_id (`int`, optional):
|
||||
Whether to send message in topic forum, It should be ID of topic forum.
|
||||
|
||||
attributes (`list`, optional):
|
||||
Optional attributes that override the inferred ones, like
|
||||
:tl:`DocumentAttributeFilename` and so on.
|
||||
|
@ -365,6 +369,7 @@ class UploadMethods:
|
|||
parse_mode=parse_mode, silent=silent, schedule=schedule,
|
||||
supports_streaming=supports_streaming, clear_draft=clear_draft,
|
||||
force_document=force_document, background=background,
|
||||
topic_id=topic_id
|
||||
)
|
||||
file = file[10:]
|
||||
captions = captions[10:]
|
||||
|
@ -378,6 +383,7 @@ class UploadMethods:
|
|||
video_note=video_note, buttons=buttons, silent=silent,
|
||||
supports_streaming=supports_streaming, schedule=schedule,
|
||||
clear_draft=clear_draft, background=background,
|
||||
topic_id=topic_id,
|
||||
**kwargs
|
||||
))
|
||||
|
||||
|
@ -407,7 +413,7 @@ class UploadMethods:
|
|||
entity, media, reply_to_msg_id=reply_to, message=caption,
|
||||
entities=msg_entities, reply_markup=markup, silent=silent,
|
||||
schedule_date=schedule, clear_draft=clear_draft,
|
||||
background=background
|
||||
background=background, top_msg_id=topic_id
|
||||
)
|
||||
return self._get_response_message(request, await self(request), entity)
|
||||
|
||||
|
@ -415,7 +421,8 @@ class UploadMethods:
|
|||
progress_callback=None, reply_to=None,
|
||||
parse_mode=(), silent=None, schedule=None,
|
||||
supports_streaming=None, clear_draft=None,
|
||||
force_document=False, background=None, ttl=None):
|
||||
force_document=False, background=None, ttl=None,
|
||||
topic_id=None):
|
||||
"""Specialized version of .send_file for albums"""
|
||||
# We don't care if the user wants to avoid cache, we will use it
|
||||
# anyway. Why? The cached version will be exactly the same thing
|
||||
|
@ -475,7 +482,7 @@ class UploadMethods:
|
|||
request = functions.messages.SendMultiMediaRequest(
|
||||
entity, reply_to_msg_id=reply_to, multi_media=media,
|
||||
silent=silent, schedule_date=schedule, clear_draft=clear_draft,
|
||||
background=background
|
||||
background=background, top_msg_id=topic_id
|
||||
)
|
||||
result = await self(request)
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class InlineResult:
|
|||
|
||||
async def click(self, entity=None, reply_to=None, comment_to=None,
|
||||
silent=False, clear_draft=False, hide_via=False,
|
||||
background=None):
|
||||
background=None, topic_id=None):
|
||||
"""
|
||||
Clicks this result and sends the associated `message`.
|
||||
|
||||
|
@ -120,6 +120,9 @@ class InlineResult:
|
|||
broadcast channel instead (effectively leaving a "comment to"
|
||||
the specified message).
|
||||
|
||||
topic_id (`int`, optional):
|
||||
Whether to send message in topic forum, It should be ID of topic forum.
|
||||
|
||||
silent (`bool`, optional):
|
||||
Whether the message should notify people with sound or not.
|
||||
Defaults to `False` (send with a notification sound unless
|
||||
|
@ -154,6 +157,7 @@ class InlineResult:
|
|||
peer=entity,
|
||||
query_id=self._query_id,
|
||||
id=self.result.id,
|
||||
top_msg_id=topic_id,
|
||||
silent=silent,
|
||||
background=background,
|
||||
clear_draft=clear_draft,
|
||||
|
|
Loading…
Reference in New Issue
Block a user