mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 04:35:24 +00:00
Add forward_messages method
This commit is contained in:
parent
740c96f0ea
commit
ae84bb267f
@ -332,21 +332,7 @@ class Client:
|
|||||||
username = username.lower()
|
username = username.lower()
|
||||||
self.peers_by_username[username] = i
|
self.peers_by_username[username] = i
|
||||||
|
|
||||||
def get_me(self):
|
def resolve_peer(self, chat_id: int or str):
|
||||||
return self.send(
|
|
||||||
functions.users.GetFullUser(
|
|
||||||
InputPeerSelf()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def send_message(self,
|
|
||||||
chat_id: int or str,
|
|
||||||
text: str,
|
|
||||||
disable_web_page_preview: bool = None,
|
|
||||||
disable_notification: bool = None,
|
|
||||||
reply_to_msg_id: int = None):
|
|
||||||
# TODO: Resolve usernames when they don't exists yet (contacts.ResolveUsername)
|
|
||||||
|
|
||||||
if chat_id in ("self", "me"):
|
if chat_id in ("self", "me"):
|
||||||
input_peer = InputPeerSelf()
|
input_peer = InputPeerSelf()
|
||||||
else:
|
else:
|
||||||
@ -380,16 +366,48 @@ class Client:
|
|||||||
else:
|
else:
|
||||||
raise PeerIdInvalid
|
raise PeerIdInvalid
|
||||||
|
|
||||||
|
return input_peer
|
||||||
|
|
||||||
|
def get_me(self):
|
||||||
|
return self.send(
|
||||||
|
functions.users.GetFullUser(
|
||||||
|
InputPeerSelf()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def send_message(self,
|
||||||
|
chat_id: int or str,
|
||||||
|
text: str,
|
||||||
|
disable_web_page_preview: bool = None,
|
||||||
|
disable_notification: bool = None,
|
||||||
|
reply_to_msg_id: int = None):
|
||||||
|
# TODO: Resolve usernames when they don't exists yet (contacts.ResolveUsername)
|
||||||
|
|
||||||
text, entities = Markdown.parse(text)
|
text, entities = Markdown.parse(text)
|
||||||
|
|
||||||
return self.send(
|
return self.send(
|
||||||
functions.messages.SendMessage(
|
functions.messages.SendMessage(
|
||||||
peer=input_peer,
|
peer=self.resolve_peer(chat_id),
|
||||||
message=text,
|
message=text,
|
||||||
random_id=self.rnd_id(),
|
|
||||||
no_webpage=disable_web_page_preview or None,
|
no_webpage=disable_web_page_preview or None,
|
||||||
silent=disable_notification or None,
|
silent=disable_notification or None,
|
||||||
reply_to_msg_id=reply_to_msg_id,
|
reply_to_msg_id=reply_to_msg_id,
|
||||||
entities=entities
|
entities=entities,
|
||||||
|
random_id=self.rnd_id(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def forward_messages(self,
|
||||||
|
chat_id: int or str,
|
||||||
|
from_chat_id: int or str,
|
||||||
|
message_ids: list,
|
||||||
|
disable_notification: bool = None):
|
||||||
|
return self.send(
|
||||||
|
functions.messages.ForwardMessages(
|
||||||
|
to_peer=self.resolve_peer(chat_id),
|
||||||
|
from_peer=self.resolve_peer(from_chat_id),
|
||||||
|
id=message_ids,
|
||||||
|
silent=disable_notification or None,
|
||||||
|
random_id=[self.rnd_id() for _ in message_ids]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user