Beispiel #1
0
 def send(self, sender: PytgbotApiBot, receiver, reply_id):
     """
     Sends a MessageWithReplies.
     First sends the `self.top_message`, and then the `self.reply_messages`
     
     Will return a list with all the results.
     
     :return: list of all results. `top_message` first, followed by the `reply_messages`.
     :rtype: list
     """
     top_message_result = self.top_message.send(sender,
                                                receiver=receiver,
                                                reply_id=reply_id)
     assert_instance(top_message_result, PytgbotApiMessage)
     reply_id = top_message_result.message_id
     # end if
     reply_messages = list(
         self.reply_messages)  # tuple -> list, just in case
     reply_results = [
         top_message_result,
     ]  # the results of the sending.
     for child_msg in reply_messages:
         if isinstance(child_msg, (list, tuple)):
             reply_messages.extend(child_msg)
             continue
         assert_instance(child_msg, Message)
         result = child_msg.send(sender, receiver, reply_id)
         reply_results.append(result)
     # end for
     return reply_results
Beispiel #2
0
 def send(self, sender: PytgbotApiBot, receiver, reply_id):
     """
     Sends a MessageWithReplies.
     First sends the `self.top_message`, and then the `self.reply_messages`
     
     Will return a list with all the results.
     
     :return: list of all results. `top_message` first, followed by the `reply_messages`.
     :rtype: list
     """
     top_message_result = self.top_message.send(sender, receiver=receiver, reply_id=reply_id)
     assert_instance(top_message_result, PytgbotApiMessage)
     reply_id = top_message_result.message_id
     # end if
     reply_messages = list(self.reply_messages)  # tuple -> list, just in case
     reply_results = [top_message_result,]  # the results of the sending.
     for child_msg in reply_messages:
         if isinstance(child_msg, (list, tuple)):
             reply_messages.extend(child_msg)
             continue
         assert_instance(child_msg, Message)
         result = child_msg.send(sender, receiver, reply_id)
         reply_results.append(result)
     # end for
     return reply_results
Beispiel #3
0
    def __init__(self,
                 media,
                 receiver=None,
                 reply_id=DEFAULT_MESSAGE_ID,
                 reply_markup=None,
                 disable_notification=False):
        """
        :param media: A array describing photos and videos to be sent, must include 2–10 items
        :type  media: list of (InputMediaPhoto|InputMediaVideo)

        Optional keyword parameters:

        :param receiver: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
        :type  receiver: int | str|unicode

        :param disable_notification: Sends the messages silently. Users will receive a notification with no sound.
        :type  disable_notification: bool

        :param reply_id: If the messages are a reply, ID of the original message
        :type  reply_id: int
        """
        for i, medium in enumerate(media):
            assert_instance(medium,
                            InputMediaPhoto,
                            InputMediaVideo,
                            parameter_name="media[{i}]".format(i=i))
        # end for
        self.media = media
        super(MediaGroupMessage,
              self).__init__(receiver, reply_id, reply_markup,
                             disable_notification)
Beispiel #4
0
    def from_list(cls, list_or_tuple):
        """
        `list[A, B, C]` -> `Message(A)` with reply-children `[B, C]`

        :param list_or_tuple:
        :return:
        """
        assert_instance(list_or_tuple, (list, tuple))
        return MessageWithReplies(list_or_tuple[0], list_or_tuple[1:])
Beispiel #5
0
    def from_list(cls, list_or_tuple):
        """
        `list[A, B, C]` -> `Message(A)` with reply-children `[B, C]`

        :param list_or_tuple:
        :return:
        """
        assert_instance(list_or_tuple, (list, tuple))
        return MessageWithReplies(list_or_tuple[0], list_or_tuple[1:])
Beispiel #6
0
    def __init__(self, game_short_name, receiver=None, reply_id=DEFAULT_MESSAGE_ID,
                 reply_markup=None, disable_notification=False):
        """
        :param game_short_name: Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
        :type  game_short_name: str|unicode

        :param receiver:
        :param reply_id:
        :param reply_markup:
        :param disable_notification:
        """
        assert_instance(game_short_name, unicode_type, parameter_name="game_short_name")
        self.game_short_name = game_short_name
        super().__init__(
            receiver=receiver, reply_id=reply_id, reply_markup=reply_markup, disable_notification=disable_notification
        )