Exemple #1
0
    async def send_document(
        cls,
        chat_id: typing.Union[base.Integer, base.String],
        document: typing.Union[base.InputFile, base.String],
        filename: str = 'document',
        thumb: typing.Union[base.InputFile, base.String, None] = None,
        caption: typing.Union[base.String, None] = None,
        parse_mode: typing.Union[base.String, None] = None,
        disable_notification: typing.Union[base.Boolean, None] = None,
        reply_to_message_id: typing.Union[base.Integer, None] = None,
        reply_markup: typing.Union[types.InlineKeyboardMarkup,
                                   types.ReplyKeyboardMarkup,
                                   types.ReplyKeyboardRemove, types.ForceReply,
                                   None] = None
    ) -> types.Message:
        reply_markup = prepare_arg(reply_markup)
        payload = generate_payload(**locals(), exclude=[filename])
        if cls.bot.parse_mode:
            payload.setdefault('parse_mode', cls.bot.parse_mode)

        files = {filename: document}
        prepare_file(payload, files, filename, document)

        result = await cls.bot.request(api.Methods.SEND_DOCUMENT, payload,
                                       files)
        return types.Message(**result)
Exemple #2
0
 def _gen_payload(_locals: dict):
     kwargs = _locals.pop('kwargs', {})
     payload = generate_payload(['__class__', 'custom_filters', 'kwargs'],
                                **_locals, **kwargs)
     return payload