Skip to content

Commit f5ca106

Browse files
author
Zaid
committed
Add *send* bound method for Gift
1 parent c358882 commit f5ca106

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

  • pyrogram/types/messages_and_media

pyrogram/types/messages_and_media/gift.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from typing import Dict, List, Optional, Union
2121

2222
import pyrogram
23-
from pyrogram import raw, types, utils
23+
from pyrogram import raw, types, utils, enums
2424

2525
from ..object import Object
2626

@@ -600,3 +600,41 @@ async def buy(self) -> Optional["types.Message"]:
600600
gift_link=self.link,
601601
new_owner_chat_id="me"
602602
)
603+
604+
async def send(
605+
self,
606+
chat_id: Union[int, str],
607+
text: Optional[str] = None,
608+
parse_mode: Optional["enums.ParseMode"] = None,
609+
entities: Optional[List["types.MessageEntity"]] = None,
610+
is_private: Optional[bool] = None,
611+
pay_for_upgrade: Optional[bool] = None,
612+
) -> Optional["types.Message"]:
613+
"""Bound method *send* of :obj:`~pyrogram.types.Gift`.
614+
615+
Use as a shortcut for:
616+
617+
.. code-block:: python
618+
619+
await client.send_gift(
620+
chat_id="me",
621+
gift_id=gift.id
622+
)
623+
624+
Example:
625+
.. code-block:: python
626+
627+
await gift.send("me")
628+
629+
Returns:
630+
:obj:`~pyrogram.types.Message`: On success, the sent message is returned.
631+
"""
632+
return await self._client.send_gift(
633+
chat_id=chat_id,
634+
gift_id=self.id,
635+
text=text,
636+
parse_mode=parse_mode,
637+
entities=entities,
638+
is_private=is_private,
639+
pay_for_upgrade=pay_for_upgrade
640+
)

0 commit comments

Comments
 (0)