From 78376c06cafba658c5400475b78f10eecdda820b Mon Sep 17 00:00:00 2001 From: Hinrich Mahler Date: Sat, 7 Nov 2020 11:06:20 +0100 Subject: [PATCH 1/4] New dice --- telegram/bot.py | 5 +++-- telegram/constants.py | 12 +++++++++++- telegram/dice.py | 11 ++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/telegram/bot.py b/telegram/bot.py index daad48e5722..9cd56269108 100644 --- a/telegram/bot.py +++ b/telegram/bot.py @@ -4255,8 +4255,9 @@ def send_dice( Args: chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target private chat. emoji (:obj:`str`, optional): Emoji on which the dice throw animation is based. - Currently, must be one of “🎲”, “🎯” or “🏀”. Dice can have values 1-6 for “🎲” and - “🎯”, and values 1-5 for “🏀” . Defaults to “🎲” + Currently, must be one of “🎲”, “🎯”, “🏀”, “⚽”, or “🎰”. Dice can have values 1-6 + for “🎲” and “🎯”, values 1-5 for “🏀” and “⚽”, and values 1-64 for “🎰”. Defaults + to “🎲”. disable_notification (:obj:`bool`, optional): Sends the message silently. Users will receive a notification with no sound. reply_to_message_id (:obj:`int`, optional): If the message is a reply, ID of the diff --git a/telegram/constants.py b/telegram/constants.py index dafde23a51a..78b8d5c44f1 100644 --- a/telegram/constants.py +++ b/telegram/constants.py @@ -83,6 +83,8 @@ DICE_DICE (:obj:`str`): '🎲' DICE_DARTS (:obj:`str`): '🎯' DICE_BASKETBALL (:obj:`str`): '🏀' + DICE_FOOTBALL (:obj:`str`): '⚽' + DICE_SLOT_MACHINE (:obj:`str`): = '🎰' DICE_ALL_EMOJI (List[:obj:`str`]): List of all supported base emoji. :class:`telegram.MessageEntity`: @@ -172,7 +174,15 @@ DICE_DICE: str = '🎲' DICE_DARTS: str = '🎯' DICE_BASKETBALL: str = '🏀' -DICE_ALL_EMOJI: List[str] = [DICE_DICE, DICE_DARTS, DICE_BASKETBALL] +DICE_FOOTBALL: str = '⚽' +DICE_SLOT_MACHINE: str = '🎰' +DICE_ALL_EMOJI: List[str] = [ + DICE_DICE, + DICE_DARTS, + DICE_BASKETBALL, + DICE_FOOTBALL, + DICE_SLOT_MACHINE, +] MESSAGEENTITY_MENTION: str = 'mention' MESSAGEENTITY_HASHTAG: str = 'hashtag' diff --git a/telegram/dice.py b/telegram/dice.py index 5332b02f64f..71be8eeefa2 100644 --- a/telegram/dice.py +++ b/telegram/dice.py @@ -41,12 +41,17 @@ class Dice(TelegramObject): 3 indicates that the basket was missed. However, this behaviour is undocumented and might be changed by Telegram. + If :attr:`emoji` is "⚽", a value of 3 to 5 currently scores a goal, while a value of 1 to + 3 indicates that the goal was missed. However, this behaviour is undocumented and might + be changed by Telegram. + Attributes: value (:obj:`int`): Value of the dice. emoji (:obj:`str`): Emoji on which the dice throw animation is based. Args: - value (:obj:`int`): Value of the dice. 1-6 for dice and darts, 1-5 for basketball. + value (:obj:`int`): Value of the dice. 1-6 for dice and darts, 1-5 for basketball and + football/soccer ball, 1-64 for slot machine. emoji (:obj:`str`): Emoji on which the dice throw animation is based. """ @@ -62,5 +67,9 @@ def __init__(self, value: int, emoji: str, **_kwargs: Any): """:const:`telegram.constants.DICE_DARTS`""" BASKETBALL: ClassVar[str] = constants.DICE_BASKETBALL """:const:`telegram.constants.DICE_BASKETBALL`""" + FOOTBALL: ClassVar[str] = constants.DICE_FOOTBALL + """:const:`telegram.constants.DICE_FOOTBALL`""" + SLOT_MACHINE: ClassVar[str] = constants.DICE_SLOT_MACHINE + """:const:`telegram.constants.DICE_SLOT_MACHINE`""" ALL_EMOJI: ClassVar[List[str]] = constants.DICE_ALL_EMOJI """:const:`telegram.constants.DICE_ALL_EMOJI`""" From 0a8e9d91c613d8ee8c15718f323c6dd4d4017010 Mon Sep 17 00:00:00 2001 From: Hinrich Mahler Date: Sat, 7 Nov 2020 11:10:06 +0100 Subject: [PATCH 2/4] Add filters --- telegram/ext/filters.py | 6 ++++++ tests/test_filters.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/telegram/ext/filters.py b/telegram/ext/filters.py index 89fbed6347c..865692037f3 100644 --- a/telegram/ext/filters.py +++ b/telegram/ext/filters.py @@ -1659,6 +1659,8 @@ class _Dice(_DiceEmoji): dice = _DiceEmoji('🎲', 'dice') darts = _DiceEmoji('🎯', 'darts') basketball = _DiceEmoji('🏀', 'basketball') + football = _DiceEmoji('⚽') + slot_machine = _DiceEmoji('🎰') dice = _Dice() """Dice Messages. If an integer or a list of integers is passed, it filters messages to only @@ -1687,6 +1689,10 @@ class _Dice(_DiceEmoji): :attr:`Filters.dice`. basketball: Dice messages with the emoji 🏀. Passing a list of integers is supported just as for :attr:`Filters.dice`. + football: Dice messages with the emoji ⚽. Passing a list of integers is supported just + as for :attr:`Filters.dice`. + slot_machine: Dice messages with the emoji 🎰. Passing a list of integers is supported just + as for :attr:`Filters.dice`. """ class language(MessageFilter): diff --git a/tests/test_filters.py b/tests/test_filters.py index 25cd8448ec8..8a4542a7c92 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -1127,6 +1127,20 @@ def test_filters_dice_type(self, update): assert not Filters.dice.darts(update) assert not Filters.dice.basketball([4])(update) + update.message.dice = Dice(5, '⚽') + assert Filters.dice.football(update) + assert Filters.dice.football([4, 5])(update) + assert not Filters.dice.dice(update) + assert not Filters.dice.darts(update) + assert not Filters.dice.football([4])(update) + + update.message.dice = Dice(5, '🎰') + assert Filters.dice.slot_machine(update) + assert Filters.dice.slot_machine([4, 5])(update) + assert not Filters.dice.dice(update) + assert not Filters.dice.darts(update) + assert not Filters.dice.slot_machine([4])(update) + def test_language_filter_single(self, update): update.message.from_user.language_code = 'en_US' assert (Filters.language('en_US'))(update) From dd972183e19a6a70357353823037058f19baadde Mon Sep 17 00:00:00 2001 From: Hinrich Mahler Date: Sat, 7 Nov 2020 11:35:58 +0100 Subject: [PATCH 3/4] Add not on slot machine values --- telegram/dice.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/telegram/dice.py b/telegram/dice.py index 71be8eeefa2..7a95643dfa8 100644 --- a/telegram/dice.py +++ b/telegram/dice.py @@ -45,6 +45,10 @@ class Dice(TelegramObject): 3 indicates that the goal was missed. However, this behaviour is undocumented and might be changed by Telegram. + If :attr:`emoji` is "🎰", each value corresponds to a unique combination of symbols, which + can be found at our `wiki `_. However, this behaviour is undocumented + and might be changed by Telegram. + Attributes: value (:obj:`int`): Value of the dice. emoji (:obj:`str`): Emoji on which the dice throw animation is based. From 2dc994fc869166cd5c58b8273ac6a7235e7d0b86 Mon Sep 17 00:00:00 2001 From: Bibo-Joshi Date: Sat, 7 Nov 2020 12:15:27 +0100 Subject: [PATCH 4/4] Fix typo --- telegram/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegram/constants.py b/telegram/constants.py index 78b8d5c44f1..188c9c24308 100644 --- a/telegram/constants.py +++ b/telegram/constants.py @@ -84,7 +84,7 @@ DICE_DARTS (:obj:`str`): '🎯' DICE_BASKETBALL (:obj:`str`): '🏀' DICE_FOOTBALL (:obj:`str`): '⚽' - DICE_SLOT_MACHINE (:obj:`str`): = '🎰' + DICE_SLOT_MACHINE (:obj:`str`): '🎰' DICE_ALL_EMOJI (List[:obj:`str`]): List of all supported base emoji. :class:`telegram.MessageEntity`: