mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-30 22:05:28 +00:00
Add support for darts mini-game with send_dice
This commit is contained in:
@@ -27,6 +27,7 @@ class SendDice(BaseClient):
|
|||||||
def send_dice(
|
def send_dice(
|
||||||
self,
|
self,
|
||||||
chat_id: Union[int, str],
|
chat_id: Union[int, str],
|
||||||
|
emoji: str = "🎲",
|
||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
schedule_date: int = None,
|
schedule_date: int = None,
|
||||||
@@ -45,6 +46,10 @@ class SendDice(BaseClient):
|
|||||||
For your personal cloud (Saved Messages) you can simply use "me" or "self".
|
For your personal cloud (Saved Messages) you can simply use "me" or "self".
|
||||||
For a contact that exists in your Telegram address book you can use his phone number (str).
|
For a contact that exists in your Telegram address book you can use his phone number (str).
|
||||||
|
|
||||||
|
emoji (``str``, *optional*):
|
||||||
|
Emoji on which the dice throw animation is based. Currently, must be one of "🎲" or "🎯".
|
||||||
|
Defauts to "🎲".
|
||||||
|
|
||||||
disable_notification (``bool``, *optional*):
|
disable_notification (``bool``, *optional*):
|
||||||
Sends the message silently.
|
Sends the message silently.
|
||||||
Users will receive a notification with no sound.
|
Users will receive a notification with no sound.
|
||||||
@@ -65,13 +70,17 @@ class SendDice(BaseClient):
|
|||||||
Example:
|
Example:
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
# Send a dice
|
||||||
app.send_dice("pyrogramlounge")
|
app.send_dice("pyrogramlounge")
|
||||||
|
|
||||||
|
# Send a dart
|
||||||
|
app.send_dice("pyrogramlounge", "🎯")
|
||||||
"""
|
"""
|
||||||
|
|
||||||
r = self.send(
|
r = self.send(
|
||||||
functions.messages.SendMedia(
|
functions.messages.SendMedia(
|
||||||
peer=self.resolve_peer(chat_id),
|
peer=self.resolve_peer(chat_id),
|
||||||
media=types.InputMediaDice(),
|
media=types.InputMediaDice(emoticon=emoji),
|
||||||
silent=disable_notification or None,
|
silent=disable_notification or None,
|
||||||
reply_to_msg_id=reply_to_message_id,
|
reply_to_msg_id=reply_to_message_id,
|
||||||
random_id=self.rnd_id(),
|
random_id=self.rnd_id(),
|
||||||
|
@@ -27,18 +27,26 @@ from ...ext.utils import encode_file_id, encode_file_ref
|
|||||||
|
|
||||||
|
|
||||||
class Dice(Object):
|
class Dice(Object):
|
||||||
"""A dice containing a value that is randomly generated by Telegram.
|
"""A dice with a random value from 1 to 6 for currently supported base emoji.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
|
emoji (``string``):
|
||||||
|
Emoji on which the dice throw animation is based.
|
||||||
|
|
||||||
value (``int``):
|
value (``int``):
|
||||||
Dice value, 1-6.
|
Value of the dice, 1-6 for currently supported base emoji.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *, client: "pyrogram.BaseClient" = None, value: int):
|
def __init__(self, *, client: "pyrogram.BaseClient" = None, emoji: str, value: int):
|
||||||
super().__init__(client)
|
super().__init__(client)
|
||||||
|
|
||||||
|
self.emoji = emoji
|
||||||
self.value = value
|
self.value = value
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(client, dice: types.MessageMediaDice) -> "Dice":
|
def _parse(client, dice: types.MessageMediaDice) -> "Dice":
|
||||||
return Dice(value=dice.value, client=client)
|
return Dice(
|
||||||
|
emoji=dice.emoticon,
|
||||||
|
value=dice.value,
|
||||||
|
client=client
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user