Skip to content

Commit 5b042a6

Browse files
committed
Add support for darts mini-game with send_dice
1 parent 8fa1ca5 commit 5b042a6

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

pyrogram/client/methods/messages/send_dice.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SendDice(BaseClient):
2727
def send_dice(
2828
self,
2929
chat_id: Union[int, str],
30+
emoji: str = "🎲",
3031
disable_notification: bool = None,
3132
reply_to_message_id: int = None,
3233
schedule_date: int = None,
@@ -45,6 +46,10 @@ def send_dice(
4546
For your personal cloud (Saved Messages) you can simply use "me" or "self".
4647
For a contact that exists in your Telegram address book you can use his phone number (str).
4748
49+
emoji (``str``, *optional*):
50+
Emoji on which the dice throw animation is based. Currently, must be one of "🎲" or "🎯".
51+
Defauts to "🎲".
52+
4853
disable_notification (``bool``, *optional*):
4954
Sends the message silently.
5055
Users will receive a notification with no sound.
@@ -65,13 +70,17 @@ def send_dice(
6570
Example:
6671
.. code-block:: python
6772
73+
# Send a dice
6874
app.send_dice("pyrogramlounge")
75+
76+
# Send a dart
77+
app.send_dice("pyrogramlounge", "🎯")
6978
"""
7079

7180
r = self.send(
7281
functions.messages.SendMedia(
7382
peer=self.resolve_peer(chat_id),
74-
media=types.InputMediaDice(),
83+
media=types.InputMediaDice(emoticon=emoji),
7584
silent=disable_notification or None,
7685
reply_to_msg_id=reply_to_message_id,
7786
random_id=self.rnd_id(),

pyrogram/client/types/messages_and_media/dice.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,26 @@
2727

2828

2929
class Dice(Object):
30-
"""A dice containing a value that is randomly generated by Telegram.
30+
"""A dice with a random value from 1 to 6 for currently supported base emoji.
3131
3232
Parameters:
33+
emoji (``string``):
34+
Emoji on which the dice throw animation is based.
35+
3336
value (``int``):
34-
Dice value, 1-6.
37+
Value of the dice, 1-6 for currently supported base emoji.
3538
"""
3639

37-
def __init__(self, *, client: "pyrogram.BaseClient" = None, value: int):
40+
def __init__(self, *, client: "pyrogram.BaseClient" = None, emoji: str, value: int):
3841
super().__init__(client)
3942

43+
self.emoji = emoji
4044
self.value = value
4145

4246
@staticmethod
4347
def _parse(client, dice: types.MessageMediaDice) -> "Dice":
44-
return Dice(value=dice.value, client=client)
48+
return Dice(
49+
emoji=dice.emoticon,
50+
value=dice.value,
51+
client=client
52+
)

0 commit comments

Comments
 (0)