1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818
1919import logging
20- from functools import partial
2120from typing import List , Match , Union , BinaryIO
2221
2322import pyrogram
@@ -2706,8 +2705,6 @@ async def forward(
27062705 self ,
27072706 chat_id : int or str ,
27082707 disable_notification : bool = None ,
2709- as_copy : bool = False ,
2710- remove_caption : bool = False ,
27112708 schedule_date : int = None
27122709 ) -> Union ["types.Message" , List ["types.Message" ]]:
27132710 """Bound method *forward* of :obj:`~pyrogram.types.Message`.
@@ -2737,15 +2734,6 @@ async def forward(
27372734 Sends the message silently.
27382735 Users will receive a notification with no sound.
27392736
2740- as_copy (``bool``, *optional*):
2741- Pass True to forward messages without the forward header (i.e.: send a copy of the message content).
2742- Defaults to False.
2743-
2744- remove_caption (``bool``, *optional*):
2745- If set to True and *as_copy* is enabled as well, media captions are not preserved when copying the
2746- message. Has no effect if *as_copy* is not enabled.
2747- Defaults to False.
2748-
27492737 schedule_date (``int``, *optional*):
27502738 Date when the message will be automatically sent. Unix time.
27512739
@@ -2755,109 +2743,13 @@ async def forward(
27552743 Raises:
27562744 RPCError: In case of a Telegram RPC error.
27572745 """
2758- if as_copy :
2759- if self .service :
2760- log .warning (f"Service messages cannot be copied. "
2761- f"chat_id: { self .chat .id } , message_id: { self .message_id } " )
2762- elif self .game and not await self ._client .storage .is_bot ():
2763- log .warning (f"Users cannot send messages with Game media type. "
2764- f"chat_id: { self .chat .id } , message_id: { self .message_id } " )
2765- elif self .text :
2766- return await self ._client .send_message (
2767- chat_id ,
2768- text = self .text .html ,
2769- parse_mode = "html" ,
2770- disable_web_page_preview = not self .web_page ,
2771- disable_notification = disable_notification ,
2772- schedule_date = schedule_date
2773- )
2774- elif self .media :
2775- caption = self .caption .html if self .caption and not remove_caption else ""
2776-
2777- send_media = partial (
2778- self ._client .send_cached_media ,
2779- chat_id = chat_id ,
2780- disable_notification = disable_notification ,
2781- schedule_date = schedule_date
2782- )
2783-
2784- if self .photo :
2785- file_id = self .photo .file_id
2786- elif self .audio :
2787- file_id = self .audio .file_id
2788- elif self .document :
2789- file_id = self .document .file_id
2790- elif self .video :
2791- file_id = self .video .file_id
2792- elif self .animation :
2793- file_id = self .animation .file_id
2794- elif self .voice :
2795- file_id = self .voice .file_id
2796- elif self .sticker :
2797- file_id = self .sticker .file_id
2798- elif self .video_note :
2799- file_id = self .video_note .file_id
2800- elif self .contact :
2801- return await self ._client .send_contact (
2802- chat_id ,
2803- phone_number = self .contact .phone_number ,
2804- first_name = self .contact .first_name ,
2805- last_name = self .contact .last_name ,
2806- vcard = self .contact .vcard ,
2807- disable_notification = disable_notification ,
2808- schedule_date = schedule_date
2809- )
2810- elif self .location :
2811- return await self ._client .send_location (
2812- chat_id ,
2813- latitude = self .location .latitude ,
2814- longitude = self .location .longitude ,
2815- disable_notification = disable_notification ,
2816- schedule_date = schedule_date
2817- )
2818- elif self .venue :
2819- return await self ._client .send_venue (
2820- chat_id ,
2821- latitude = self .venue .location .latitude ,
2822- longitude = self .venue .location .longitude ,
2823- title = self .venue .title ,
2824- address = self .venue .address ,
2825- foursquare_id = self .venue .foursquare_id ,
2826- foursquare_type = self .venue .foursquare_type ,
2827- disable_notification = disable_notification ,
2828- schedule_date = schedule_date
2829- )
2830- elif self .poll :
2831- return await self ._client .send_poll (
2832- chat_id ,
2833- question = self .poll .question ,
2834- options = [opt .text for opt in self .poll .options ],
2835- disable_notification = disable_notification ,
2836- schedule_date = schedule_date
2837- )
2838- elif self .game :
2839- return await self ._client .send_game (
2840- chat_id ,
2841- game_short_name = self .game .short_name ,
2842- disable_notification = disable_notification
2843- )
2844- else :
2845- raise ValueError ("Unknown media type" )
2846-
2847- if self .sticker or self .video_note : # Sticker and VideoNote should have no caption
2848- return await send_media (file_id = file_id )
2849- else :
2850- return await send_media (file_id = file_id , caption = caption , parse_mode = "html" )
2851- else :
2852- raise ValueError ("Can't copy this message" )
2853- else :
2854- return await self ._client .forward_messages (
2855- chat_id = chat_id ,
2856- from_chat_id = self .chat .id ,
2857- message_ids = self .message_id ,
2858- disable_notification = disable_notification ,
2859- schedule_date = schedule_date
2860- )
2746+ return await self ._client .forward_messages (
2747+ chat_id = chat_id ,
2748+ from_chat_id = self .chat .id ,
2749+ message_ids = self .message_id ,
2750+ disable_notification = disable_notification ,
2751+ schedule_date = schedule_date
2752+ )
28612753
28622754 async def delete (self , revoke : bool = True ):
28632755 """Bound method *delete* of :obj:`~pyrogram.types.Message`.
0 commit comments