How to use the aiogram.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 / types / message.py View on Github external
from .location import Location
from .message_entity import MessageEntity
from .passport_data import PassportData
from .photo_size import PhotoSize
from .sticker import Sticker
from .successful_payment import SuccessfulPayment
from .user import User
from .venue import Venue
from .video import Video
from .video_note import VideoNote
from .voice import Voice
from ..utils import helper
from ..utils import markdown as md


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

    https://core.telegram.org/bots/api#message
    """
    message_id: base.Integer = fields.Field()
    from_user: User = fields.Field(alias='from', base=User)
    date: datetime.datetime = fields.DateTimeField()
    chat: Chat = fields.Field(base=Chat)
    forward_from: User = fields.Field(base=User)
    forward_from_chat: Chat = fields.Field(base=Chat)
    forward_from_message_id: base.Integer = fields.Field()
    forward_signature: base.String = fields.Field()
    forward_date: datetime.datetime = fields.DateTimeField()
    reply_to_message: 'Message' = fields.Field(base='Message')
    edit_date: datetime.datetime = fields.DateTimeField()
github aiogram / aiogram / aiogram / types / user.py View on Github external
from __future__ import annotations

from typing import Optional

import babel

from . import base
from . import fields
from ..utils import markdown


class User(base.TelegramObject):
    """
    This object represents a Telegram user or bot.

    https://core.telegram.org/bots/api#user
    """
    id: base.Integer = fields.Field()
    is_bot: base.Boolean = fields.Field()
    first_name: base.String = fields.Field()
    last_name: base.String = fields.Field()
    username: base.String = fields.Field()
    language_code: base.String = fields.Field()

    @property
    def full_name(self):
        """
        You can get full name of user.
github aiogram / aiogram / aiogram / types / successful_payment.py View on Github external
from . import base
from . import fields
from .order_info import OrderInfo


class SuccessfulPayment(base.TelegramObject):
    """
    This object contains basic information about a successful payment.

    https://core.telegram.org/bots/api#successfulpayment
    """
    currency: base.String = fields.Field()
    total_amount: base.Integer = fields.Field()
    invoice_payload: base.String = fields.Field()
    shipping_option_id: base.String = fields.Field()
    order_info: OrderInfo = fields.Field(base=OrderInfo)
    telegram_payment_charge_id: base.String = fields.Field()
    provider_payment_charge_id: base.String = fields.Field()
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 / update.py View on Github external
from __future__ import annotations

from . import base
from . import fields
from .callback_query import CallbackQuery
from .chosen_inline_result import ChosenInlineResult
from .inline_query import InlineQuery
from .message import Message
from .poll import Poll
from .pre_checkout_query import PreCheckoutQuery
from .shipping_query import ShippingQuery
from ..utils import helper


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

    https://core.telegram.org/bots/api#update
    """
    update_id: base.Integer = fields.Field()
    message: Message = fields.Field(base=Message)
    edited_message: Message = fields.Field(base=Message)
    channel_post: Message = fields.Field(base=Message)
    edited_channel_post: Message = fields.Field(base=Message)
    inline_query: InlineQuery = fields.Field(base=InlineQuery)
    chosen_inline_result: ChosenInlineResult = fields.Field(base=ChosenInlineResult)
    callback_query: CallbackQuery = fields.Field(base=CallbackQuery)
    shipping_query: ShippingQuery = fields.Field(base=ShippingQuery)
    pre_checkout_query: PreCheckoutQuery = fields.Field(base=PreCheckoutQuery)
github aiogram / aiogram / aiogram / types / input_media.py View on Github external
import io
import secrets
import typing

from . import base
from . import fields
from .input_file import InputFile

ATTACHMENT_PREFIX = 'attach://'


class InputMedia(base.TelegramObject):
    """
    This object represents the content of a media message to be sent. It should be one of
     - InputMediaPhoto
     - InputMediaVideo

    That is only base class.

    https://core.telegram.org/bots/api#inputmedia
    """
    type: base.String = fields.Field(default='photo')
    media: base.String = fields.Field()
    thumb: typing.Union[base.InputFile, base.String] = fields.Field()
    caption: base.String = fields.Field()
    parse_mode: base.Boolean = fields.Field()

    def __init__(self, *args, **kwargs):
github aiogram / aiogram / aiogram / types / user_profile_photos.py View on Github external
import typing

from . import base
from . import fields
from .photo_size import PhotoSize


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

    https://core.telegram.org/bots/api#userprofilephotos
    """
    total_count: base.Integer = fields.Field()
    photos: typing.List[typing.List[PhotoSize]] = fields.ListOfLists(base=PhotoSize)
github aiogram / aiogram / aiogram / types / shipping_option.py View on Github external
import typing

from . import base
from . import fields
from .labeled_price import LabeledPrice


class ShippingOption(base.TelegramObject):
    """
    This object represents one shipping option.

    https://core.telegram.org/bots/api#shippingoption
    """
    id: base.String = fields.Field()
    title: base.String = fields.Field()
    prices: typing.List[LabeledPrice] = fields.ListField(base=LabeledPrice)

    def __init__(self, id: base.String, title: base.String, prices: typing.List[LabeledPrice] = None):
        if prices is None:
            prices = []

        super(ShippingOption, self).__init__(id=id, title=title, prices=prices)

    def add(self, price: LabeledPrice):
github aiogram / aiogram / aiogram / types / reply_keyboard.py View on Github external
import typing

from . import base
from . import fields


class ReplyKeyboardMarkup(base.TelegramObject):
    """
    This object represents a custom keyboard with reply options (see Introduction to bots for details and examples).

    https://core.telegram.org/bots/api#replykeyboardmarkup
    """
    keyboard: 'typing.List[typing.List[KeyboardButton]]' = fields.ListOfLists(base='KeyboardButton', default=[])
    resize_keyboard: base.Boolean = fields.Field()
    one_time_keyboard: base.Boolean = fields.Field()
    selective: base.Boolean = fields.Field()

    def __init__(self, keyboard: 'typing.List[typing.List[KeyboardButton]]' = None,
                 resize_keyboard: base.Boolean = None,
                 one_time_keyboard: base.Boolean = None,
                 selective: base.Boolean = None,
                 row_width: base.Integer = 3):
        super(ReplyKeyboardMarkup, self).__init__(keyboard=keyboard, resize_keyboard=resize_keyboard,
github aiogram / aiogram / aiogram / types / game.py View on Github external
import typing

from . import base
from . import fields
from .animation import Animation
from .message_entity import MessageEntity
from .photo_size import PhotoSize


class Game(base.TelegramObject):
    """
    This object represents a game.

    Use BotFather to create and edit games, their short names will act as unique identifiers.

    https://core.telegram.org/bots/api#game
    """
    title: base.String = fields.Field()
    description: base.String = fields.Field()
    photo: typing.List[PhotoSize] = fields.ListField(base=PhotoSize)
    text: base.String = fields.Field()
    text_entities: typing.List[MessageEntity] = fields.ListField(base=MessageEntity)
    animation: Animation = fields.Field(base=Animation)