How to use the aiogram.api.types.base.TelegramObject 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 / api / types / update.py View on Github external
from typing import TYPE_CHECKING, Optional

from .base import TelegramObject

if TYPE_CHECKING:  # pragma: no cover
    from .inline_query import InlineQuery
    from .shipping_query import ShippingQuery
    from .message import Message
    from .callback_query import CallbackQuery
    from .poll import Poll
    from .pre_checkout_query import PreCheckoutQuery
    from .chosen_inline_result import ChosenInlineResult


class Update(TelegramObject):
    """
    This object represents an incoming update.
    At most one of the optional parameters can be present in any given update.

    Source: https://core.telegram.org/bots/api#update
    """

    update_id: int
    """The update‘s unique identifier. Update identifiers start from a certain positive number and
    increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it
    allows you to ignore repeated updates or to restore the correct update sequence, should
    they get out of order. If there are no new updates for at least a week, then identifier of
    the next update will be chosen randomly instead of sequentially."""
    message: Optional[Message] = None
    """New incoming message of any kind — text, photo, sticker, etc."""
    edited_message: Optional[Message] = None
github aiogram / aiogram / aiogram / api / types / chat_permissions.py View on Github external
from __future__ import annotations

from typing import Optional

from .base import TelegramObject


class ChatPermissions(TelegramObject):
    """
    Describes actions that a non-administrator user is allowed to take in a chat.

    Source: https://core.telegram.org/bots/api#chatpermissions
    """

    can_send_messages: Optional[bool] = None
    """True, if the user is allowed to send text messages, contacts, locations and venues"""
    can_send_media_messages: Optional[bool] = None
    """True, if the user is allowed to send audios, documents, photos, videos, video notes and
    voice notes, implies can_send_messages"""
    can_send_polls: Optional[bool] = None
    """True, if the user is allowed to send polls, implies can_send_messages"""
    can_send_other_messages: Optional[bool] = None
    """True, if the user is allowed to send animations, games, stickers and use inline bots,
    implies can_send_media_messages"""
github aiogram / aiogram / aiogram / api / types / user_profile_photos.py View on Github external
from __future__ import annotations

from typing import TYPE_CHECKING, List

from .base import TelegramObject

if TYPE_CHECKING:  # pragma: no cover
    from .photo_size import PhotoSize


class UserProfilePhotos(TelegramObject):
    """
    This object represent a user's profile pictures.

    Source: https://core.telegram.org/bots/api#userprofilephotos
    """

    total_count: int
    """Total number of profile pictures the target user has"""
    photos: List[List[PhotoSize]]
    """Requested profile pictures (in up to 4 sizes each)"""
github aiogram / aiogram / aiogram / api / types / file.py View on Github external
from __future__ import annotations

from typing import Optional

from .base import TelegramObject


class File(TelegramObject):
    """
    This object represents a file ready to be downloaded. The file can be downloaded via the link
    https://api.telegram.org/file/bot/. It is guaranteed that the link will be
    valid for at least 1 hour. When the link expires, a new one can be requested by calling
    getFile.
    Maximum file size to download is 20 MB

    Source: https://core.telegram.org/bots/api#file
    """

    file_id: str
    """Identifier for this file"""
    file_size: Optional[int] = None
    """File size, if known"""
    file_path: Optional[str] = None
    """File path. Use https://api.telegram.org/file/bot/ to get the file."""
github aiogram / aiogram / aiogram / api / types / game_high_score.py View on Github external
from __future__ import annotations

from typing import TYPE_CHECKING

from .base import TelegramObject

if TYPE_CHECKING:  # pragma: no cover
    from .user import User


class GameHighScore(TelegramObject):
    """
    This object represents one row of the high scores table for a game.
    And that‘s about all we’ve got for now.
    If you've got any questions, please check out our Bot FAQ

    Source: https://core.telegram.org/bots/api#gamehighscore
    """

    position: int
    """Position in high score table for the game"""
    user: User
    """User"""
    score: int
    """Score"""
github aiogram / aiogram / aiogram / api / types / document.py View on Github external
from __future__ import annotations

from typing import TYPE_CHECKING, Optional

from .base import TelegramObject

if TYPE_CHECKING:  # pragma: no cover
    from .photo_size import PhotoSize


class Document(TelegramObject):
    """
    This object represents a general file (as opposed to photos, voice messages and audio files).

    Source: https://core.telegram.org/bots/api#document
    """

    file_id: str
    """Identifier for this file"""
    thumb: Optional[PhotoSize] = None
    """Document thumbnail as defined by sender"""
    file_name: Optional[str] = None
    """Original filename as defined by sender"""
    mime_type: Optional[str] = None
    """MIME type of the file as defined by sender"""
    file_size: Optional[int] = None
    """File size"""
github aiogram / aiogram / aiogram / api / types / sticker.py View on Github external
from __future__ import annotations

from typing import TYPE_CHECKING, Optional

from .base import TelegramObject

if TYPE_CHECKING:  # pragma: no cover
    from .photo_size import PhotoSize
    from .mask_position import MaskPosition


class Sticker(TelegramObject):
    """
    This object represents a sticker.

    Source: https://core.telegram.org/bots/api#sticker
    """

    file_id: str
    """Identifier for this file"""
    width: int
    """Sticker width"""
    height: int
    """Sticker height"""
    is_animated: bool
    """True, if the sticker is animated"""
    thumb: Optional[PhotoSize] = None
    """Sticker thumbnail in the .webp or .jpg format"""
github aiogram / aiogram / aiogram / api / types / reply_keyboard_remove.py View on Github external
from __future__ import annotations

from typing import Optional

from .base import TelegramObject


class ReplyKeyboardRemove(TelegramObject):
    """
    Upon receiving a message with this object, Telegram clients will remove the current custom
    keyboard and display the default letter-keyboard. By default, custom keyboards are displayed
    until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are
    hidden immediately after the user presses a button (see ReplyKeyboardMarkup).

    Source: https://core.telegram.org/bots/api#replykeyboardremove
    """

    remove_keyboard: bool
    """Requests clients to remove the custom keyboard (user will not be able to summon this
    keyboard; if you want to hide the keyboard from sight but keep it accessible, use
    one_time_keyboard in ReplyKeyboardMarkup)"""
    selective: Optional[bool] = None
    """Use this parameter if you want to remove the keyboard for specific users only. Targets: 1)
    users that are @mentioned in the text of the Message object; 2) if the bot's message is a
github aiogram / aiogram / aiogram / api / types / response_parameters.py View on Github external
from __future__ import annotations

from typing import Optional

from .base import TelegramObject


class ResponseParameters(TelegramObject):
    """
    Contains information about why a request was unsuccessful.

    Source: https://core.telegram.org/bots/api#responseparameters
    """

    migrate_to_chat_id: Optional[int] = None
    """The group has been migrated to a supergroup with the specified identifier. This number may
    be greater than 32 bits and some programming languages may have difficulty/silent defects
    in interpreting it. But it is smaller than 52 bits, so a signed 64 bit integer or
    double-precision float type are safe for storing this identifier."""
    retry_after: Optional[int] = None
    """In case of exceeding flood control, the number of seconds left to wait before the request
    can be repeated"""
github aiogram / aiogram / aiogram / api / types / message.py View on Github external
from .venue import Venue
    from .user import User
    from .passport_data import PassportData
    from .video_note import VideoNote
    from .audio import Audio
    from .successful_payment import SuccessfulPayment
    from .sticker import Sticker
    from .poll import Poll
    from .chat import Chat
    from .document import Document
    from .inline_keyboard_markup import InlineKeyboardMarkup
    from .voice import Voice
    from .video import Video


class Message(TelegramObject):
    """
    This object represents a message.

    Source: https://core.telegram.org/bots/api#message
    """

    message_id: int
    """Unique message identifier inside this chat"""
    date: datetime.datetime
    """Date the message was sent in Unix time"""
    chat: Chat
    """Conversation the message belongs to"""
    from_user: Optional[User] = Field(None, alias="from")
    """Sender, empty for messages sent to channels"""
    forward_from: Optional[User] = None
    """For forwarded messages, sender of the original message"""