How to use the aiogram.types.base function in aiogram

To help you get started, we’ve selected a few aiogram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aiogram / aiogram / aiogram / types / input_media.py View on Github external
super(InputMediaDocument, self).__init__(type='document', media=media, thumb=thumb,
                                                 caption=caption, parse_mode=parse_mode,
                                                 conf=kwargs)

        if isinstance(media, (io.IOBase, InputFile)):
            self.file = media


class InputMediaAudio(InputMedia):
    """
    Represents an animation file (GIF or H.264/MPEG-4 AVC video without sound) to be sent.

    https://core.telegram.org/bots/api#inputmediaanimation
    """

    width: base.Integer = fields.Field()
    height: base.Integer = fields.Field()
    duration: base.Integer = fields.Field()
    performer: base.String = fields.Field()
    title: base.String = fields.Field()

    def __init__(self, media: base.InputFile,
                 thumb: typing.Union[base.InputFile, base.String] = None,
                 caption: base.String = None,
                 width: base.Integer = None, height: base.Integer = None,
                 duration: base.Integer = None,
                 performer: base.String = None,
                 title: base.String = None,
                 parse_mode: base.Boolean = None, **kwargs):
        super(InputMediaAudio, self).__init__(type='audio', media=media, thumb=thumb, caption=caption,
                                              width=width, height=height, duration=duration,
                                              performer=performer, title=title,
github aiogram / aiogram / aiogram / types / inline_query.py View on Github external
import typing

from . import base
from . import fields
from .inline_query_result import InlineQueryResult
from .location import Location
from .user import User


class InlineQuery(base.TelegramObject):
    """
    This object represents an incoming inline query.

    When the user sends an empty query, your bot could return some default or trending results.

    https://core.telegram.org/bots/api#inlinequery
    """
    id: base.String = fields.Field()
    from_user: User = fields.Field(alias='from', base=User)
    location: Location = fields.Field(base=Location)
    query: base.String = fields.Field()
    offset: base.String = fields.Field()

    async def answer(self,
                     results: typing.List[InlineQueryResult],
                     cache_time: typing.Union[base.Integer, None] = None,
github aiogram / aiogram / aiogram / types / video_note.py View on Github external
from . import fields
from . import mixins
from .photo_size import PhotoSize


class VideoNote(base.TelegramObject, mixins.Downloadable):
    """
    This object represents a video message (available in Telegram apps as of v.4.0).

    https://core.telegram.org/bots/api#videonote
    """
    file_id: base.String = fields.Field()
    length: base.Integer = fields.Field()
    duration: base.Integer = fields.Field()
    thumb: PhotoSize = fields.Field(base=PhotoSize)
    file_size: base.Integer = fields.Field()
github aiogram / aiogram / aiogram / types / poll.py View on Github external
import typing

from . import base
from . import fields


class PollOption(base.TelegramObject):
    text: base.String = fields.Field()
    voter_count: base.Integer = fields.Field()


class Poll(base.TelegramObject):
    id: base.String = fields.Field()
    question: base.String = fields.Field()
    options: typing.List[PollOption] = fields.ListField(base=PollOption)
    is_closed: base.Boolean = fields.Field()
github aiogram / aiogram / aiogram / types / login_url.py View on Github external
from . import base
from . import fields


class LoginUrl(base.TelegramObject):
    """
    This object represents a parameter of the inline keyboard button used to automatically authorize a user.
    Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram.
    All the user needs to do is tap/click a button and confirm that they want to log in.

    https://core.telegram.org/bots/api#loginurl
    """
    url: base.String = fields.Field()
    forward_text: base.String = fields.Field()
    bot_username: base.String = fields.Field()
    request_write_access: base.Boolean = fields.Field()

    def __init__(self,
                 url: base.String,
                 forward_text: base.String = None,
                 bot_username: base.String = None,
github aiogram / aiogram / aiogram / types / chat.py View on Github external
from __future__ import annotations

import asyncio
import datetime
import typing

from . import base
from . import fields
from .chat_permissions import ChatPermissions
from .chat_photo import ChatPhoto
from ..utils import helper
from ..utils import markdown


class Chat(base.TelegramObject):
    """
    This object represents a chat.

    https://core.telegram.org/bots/api#chat
    """
    id: base.Integer = fields.Field()
    type: base.String = fields.Field()
    title: base.String = fields.Field()
    username: base.String = fields.Field()
    first_name: base.String = fields.Field()
    last_name: base.String = fields.Field()
    all_members_are_administrators: base.Boolean = fields.Field()
    photo: ChatPhoto = fields.Field(base=ChatPhoto)
    description: base.String = fields.Field()
    invite_link: base.String = fields.Field()
    pinned_message: 'Message' = fields.Field(base='Message')
github aiogram / aiogram / aiogram / types / venue.py View on Github external
from . import base
from . import fields
from .location import Location


class Venue(base.TelegramObject):
    """
    This object represents a venue.

    https://core.telegram.org/bots/api#venue
    """
    location: Location = fields.Field(base=Location)
    title: base.String = fields.Field()
    address: base.String = fields.Field()
    foursquare_id: base.String = fields.Field()
    foursquare_type: base.String = fields.Field()
github aiogram / aiogram / aiogram / types / passport_element_error.py View on Github external
file_hash: base.String = fields.Field()

    def __init__(self, source: base.String, type: base.String, file_hash: base.String, message: base.String):
        super(PassportElementErrorReverseSide, self).__init__(source=source, type=type, file_hash=file_hash,
                                                              message=message)


class PassportElementErrorSelfie(PassportElementError):
    """
    Represents an issue with the selfie with a document.
    The error is considered resolved when the file with the selfie changes.

    https://core.telegram.org/bots/api#passportelementerrorselfie
    """

    file_hash: base.String = fields.Field()

    def __init__(self, source: base.String, type: base.String, file_hash: base.String, message: base.String):
        super(PassportElementErrorSelfie, self).__init__(source=source, type=type, file_hash=file_hash,
                                                         message=message)