Telegram Dice Robot Development Programming
Budget: $1,500 – $3,000 USD
Telegram bot needs to have the following functions
1. The telegraph robot needs to regularly roll dice within the group and calculate the results.
2. You also need to write a filter to filter the required dice valuesclass _Dice(MessageFilter):
__slots__ = ("emoji", "values")
def __init__(self, values: Optional[SCT[int]] = None, emoji: Optional[DiceEmojiEnum] = None):
super().__init__()
self.emoji: Optional[DiceEmojiEnum] = emoji
self.values: Optional[Collection[int]] = [values] if isinstance(values, int) else values
if emoji: # for filters.Dice.BASKETBALL
self.name = f"filters.Dice.{emoji.name}"
if self.values and emoji: # for filters.Dice.Dice(4) SLOT_MACHINE -> SlotMachine
self.name = f"filters.Dice.{emoji.name.title().replace('_', '')}({self.values})"
elif values: # for filters.Dice(4)
self.name = f"filters.Dice({self.values})"
else:
self.name = "filters.Dice.ALL"
def filter(self, message: Message) -> bool:
if not (dice := message.dice): # no dice
return False
if self.emoji:
emoji_match = dice.emoji == self.emoji
if self.values:
return dice.value in self.values and emoji_match # emoji and value
return emoji_match # emoji, no value
return dice.value in self.values if self.values else True # no emoji, only value
class Dice(_Dice):
"""Dice Messages. If an integer or a list of integers is passed, it filters messages to only
allow those whose dice value is appearing in the given list.
3. Write this complete set of code to replace the dice information def init(self, value:Optional[SCT[int]] = None, emoji:Optional[DiceEmojiEnum] = None):
super().init()
self.emoji: optional[DiceEmojiEnum] = emoticon
self.values: optional [Collection[int]] = [value] if isinstance(values, int) else value
if emoji: # for filters.Dice.BASKETBALL
self.name = f"filters.Dice.{emoji.name}"
if self.values and emoji: # forfilters.Dice.Dice(4) SLOT_MACHINE -> SlotMachine
self.name = f"filters.Dice.{emoji.name.title().replace('_', '')}({self.values})"
elif value: # for filters.Dice(4)
self.name = f"filters.Dice({self.values})"
others:
self.name = "filters.Dice.ALL"
1. The telegraph robot needs to regularly roll dice within the group and calculate the results.
2. You also need to write a filter to filter the required dice valuesclass _Dice(MessageFilter):
__slots__ = ("emoji", "values")
def __init__(self, values: Optional[SCT[int]] = None, emoji: Optional[DiceEmojiEnum] = None):
super().__init__()
self.emoji: Optional[DiceEmojiEnum] = emoji
self.values: Optional[Collection[int]] = [values] if isinstance(values, int) else values
if emoji: # for filters.Dice.BASKETBALL
self.name = f"filters.Dice.{emoji.name}"
if self.values and emoji: # for filters.Dice.Dice(4) SLOT_MACHINE -> SlotMachine
self.name = f"filters.Dice.{emoji.name.title().replace('_', '')}({self.values})"
elif values: # for filters.Dice(4)
self.name = f"filters.Dice({self.values})"
else:
self.name = "filters.Dice.ALL"
def filter(self, message: Message) -> bool:
if not (dice := message.dice): # no dice
return False
if self.emoji:
emoji_match = dice.emoji == self.emoji
if self.values:
return dice.value in self.values and emoji_match # emoji and value
return emoji_match # emoji, no value
return dice.value in self.values if self.values else True # no emoji, only value
class Dice(_Dice):
"""Dice Messages. If an integer or a list of integers is passed, it filters messages to only
allow those whose dice value is appearing in the given list.
3. Write this complete set of code to replace the dice information def init(self, value:Optional[SCT[int]] = None, emoji:Optional[DiceEmojiEnum] = None):
super().init()
self.emoji: optional[DiceEmojiEnum] = emoticon
self.values: optional [Collection[int]] = [value] if isinstance(values, int) else value
if emoji: # for filters.Dice.BASKETBALL
self.name = f"filters.Dice.{emoji.name}"
if self.values and emoji: # forfilters.Dice.Dice(4) SLOT_MACHINE -> SlotMachine
self.name = f"filters.Dice.{emoji.name.title().replace('_', '')}({self.values})"
elif value: # for filters.Dice(4)
self.name = f"filters.Dice({self.values})"
others:
self.name = "filters.Dice.ALL"