mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-06 07:50:32 +00:00
Update to 4.3 Bot API. LoginUrl.
This commit is contained in:
parent
9c0bc2d489
commit
b70778fcdb
10 changed files with 82 additions and 14 deletions
|
|
@ -5,6 +5,7 @@
|
|||
[](https://pypi.python.org/pypi/aiogram)
|
||||
[](https://pypi.python.org/pypi/aiogram)
|
||||
[](https://pypi.python.org/pypi/aiogram)
|
||||
[](https://core.telegram.org/bots/api)
|
||||
[](http://aiogram.readthedocs.io/en/latest/?badge=latest)
|
||||
[](https://github.com/aiogram/aiogram/issues)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@ AIOGramBot
|
|||
:target: https://pypi.python.org/pypi/aiogram
|
||||
:alt: Supported python versions
|
||||
|
||||
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-4.3-blue.svg?style=flat-square&logo=telegram
|
||||
:target: https://core.telegram.org/bots/api
|
||||
:alt: Telegram Bot API
|
||||
|
||||
.. image:: https://img.shields.io/readthedocs/pip/stable.svg?style=flat-square
|
||||
:target: http://aiogram.readthedocs.io/en/latest/?badge=latest
|
||||
:alt: Documentation Status
|
||||
|
|
|
|||
|
|
@ -38,5 +38,5 @@ __all__ = [
|
|||
'utils'
|
||||
]
|
||||
|
||||
__version__ = '2.1.1.dev1'
|
||||
__api_version__ = '4.2'
|
||||
__version__ = '2.2.dev1'
|
||||
__api_version__ = '4.3'
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ class Methods(Helper):
|
|||
"""
|
||||
Helper for Telegram API Methods listed on https://core.telegram.org/bots/api
|
||||
|
||||
List is updated to Bot API 4.2
|
||||
List is updated to Bot API 4.3
|
||||
"""
|
||||
mode = HelperMode.lowerCamelCase
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ from .input_message_content import InputContactMessageContent, InputLocationMess
|
|||
from .invoice import Invoice
|
||||
from .labeled_price import LabeledPrice
|
||||
from .location import Location
|
||||
from .login_url import LoginUrl
|
||||
from .mask_position import MaskPosition
|
||||
from .message import ContentType, ContentTypes, Message, ParseMode
|
||||
from .message_entity import MessageEntity, MessageEntityType
|
||||
|
|
@ -126,6 +127,7 @@ __all__ = (
|
|||
'KeyboardButton',
|
||||
'LabeledPrice',
|
||||
'Location',
|
||||
'LoginUrl',
|
||||
'MaskPosition',
|
||||
'MediaGroup',
|
||||
'Message',
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import typing
|
|||
from . import base
|
||||
from . import fields
|
||||
from .callback_game import CallbackGame
|
||||
from .login_url import LoginUrl
|
||||
|
||||
|
||||
class InlineKeyboardMarkup(base.TelegramObject):
|
||||
|
|
@ -16,10 +17,16 @@ class InlineKeyboardMarkup(base.TelegramObject):
|
|||
"""
|
||||
inline_keyboard: 'typing.List[typing.List[InlineKeyboardButton]]' = fields.ListOfLists(base='InlineKeyboardButton')
|
||||
|
||||
def __init__(self, row_width=3, inline_keyboard=None):
|
||||
def __init__(self, row_width=3, inline_keyboard=None, **kwargs):
|
||||
if inline_keyboard is None:
|
||||
inline_keyboard = []
|
||||
super(InlineKeyboardMarkup, self).__init__(conf={'row_width': row_width}, inline_keyboard=inline_keyboard)
|
||||
|
||||
conf = kwargs.pop('conf', {}) or {}
|
||||
conf['row_width'] = row_width
|
||||
|
||||
super(InlineKeyboardMarkup, self).__init__(**kwargs,
|
||||
conf=conf,
|
||||
inline_keyboard=inline_keyboard)
|
||||
|
||||
@property
|
||||
def row_width(self):
|
||||
|
|
@ -84,16 +91,26 @@ class InlineKeyboardButton(base.TelegramObject):
|
|||
"""
|
||||
text: base.String = fields.Field()
|
||||
url: base.String = fields.Field()
|
||||
login_url: LoginUrl = fields.Field(base=LoginUrl)
|
||||
callback_data: base.String = fields.Field()
|
||||
switch_inline_query: base.String = fields.Field()
|
||||
switch_inline_query_current_chat: base.String = fields.Field()
|
||||
callback_game: CallbackGame = fields.Field(base=CallbackGame)
|
||||
pay: base.Boolean = fields.Field()
|
||||
|
||||
def __init__(self, text: base.String, url: base.String = None, callback_data: base.String = None,
|
||||
switch_inline_query: base.String = None, switch_inline_query_current_chat: base.String = None,
|
||||
callback_game: CallbackGame = None, pay: base.Boolean = None):
|
||||
super(InlineKeyboardButton, self).__init__(text=text, url=url, callback_data=callback_data,
|
||||
def __init__(self, text: base.String,
|
||||
url: base.String = None,
|
||||
login_url: LoginUrl = None,
|
||||
callback_data: base.String = None,
|
||||
switch_inline_query: base.String = None,
|
||||
switch_inline_query_current_chat: base.String = None,
|
||||
callback_game: CallbackGame = None,
|
||||
pay: base.Boolean = None, **kwargs):
|
||||
super(InlineKeyboardButton, self).__init__(text=text,
|
||||
url=url,
|
||||
login_url=login_url,
|
||||
callback_data=callback_data,
|
||||
switch_inline_query=switch_inline_query,
|
||||
switch_inline_query_current_chat=switch_inline_query_current_chat,
|
||||
callback_game=callback_game, pay=pay)
|
||||
callback_game=callback_game,
|
||||
pay=pay, **kwargs)
|
||||
|
|
|
|||
30
aiogram/types/login_url.py
Normal file
30
aiogram/types/login_url.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
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,
|
||||
request_write_access: base.Boolean = None,
|
||||
**kwargs):
|
||||
super(LoginUrl, self).__init__(
|
||||
url=url,
|
||||
forward_text=forward_text,
|
||||
bot_username=bot_username,
|
||||
request_write_access=request_write_access,
|
||||
**kwargs
|
||||
)
|
||||
|
|
@ -14,7 +14,7 @@ from .contact import Contact
|
|||
from .document import Document
|
||||
from .force_reply import ForceReply
|
||||
from .game import Game
|
||||
from .inline_keyboard import InlineKeyboardMarkup
|
||||
from .inline_keyboard import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from .input_media import MediaGroup, InputMedia
|
||||
from .invoice import Invoice
|
||||
from .location import Location
|
||||
|
|
@ -87,6 +87,7 @@ class Message(base.TelegramObject):
|
|||
connected_website: base.String = fields.Field()
|
||||
passport_data: PassportData = fields.Field(base=PassportData)
|
||||
poll: Poll = fields.Field(base=Poll)
|
||||
reply_markup: typing.List[typing.List[InlineKeyboardButton]] = fields.ListOfLists(base=InlineKeyboardButton)
|
||||
|
||||
@property
|
||||
@functools.lru_cache()
|
||||
|
|
|
|||
|
|
@ -451,6 +451,11 @@ class ResultIdDuplicate(BadRequest):
|
|||
text = 'Result ID duplicate'
|
||||
|
||||
|
||||
class BotDomainInvalid(BadRequest):
|
||||
match = 'bot_domain_invalid'
|
||||
text = 'Invalid bot domain'
|
||||
|
||||
|
||||
class NotFound(TelegramAPIError, _MatchErrorMixin):
|
||||
__group = True
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@ Welcome to aiogram's documentation!
|
|||
===================================
|
||||
|
||||
|
||||
.. image:: https://img.shields.io/badge/telegram-aiogram-blue.svg?style=flat-square
|
||||
:target: https://t.me/aiogram_live
|
||||
:alt: [Telegram] aiogram live
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/aiogram.svg?style=flat-square
|
||||
:target: https://pypi.python.org/pypi/aiogram
|
||||
:alt: PyPi Package Version
|
||||
|
|
@ -10,13 +14,17 @@ Welcome to aiogram's documentation!
|
|||
:target: https://pypi.python.org/pypi/aiogram
|
||||
:alt: PyPi status
|
||||
|
||||
.. image:: https://img.shields.io/pypi/dm/aiogram.svg?style=flat-square
|
||||
:target: https://pypi.python.org/pypi/aiogram
|
||||
:alt: PyPi downloads
|
||||
|
||||
.. image:: https://img.shields.io/pypi/pyversions/aiogram.svg?style=flat-square
|
||||
:target: https://pypi.python.org/pypi/aiogram
|
||||
:alt: Supported python versions
|
||||
|
||||
.. image:: https://img.shields.io/pypi/dm/aiogram.svg?style=flat-square
|
||||
:target: https://pypi.python.org/pypi/aiogram
|
||||
:alt: PyPi downloads
|
||||
.. image:: https://img.shields.io/badge/Telegram%20Bot%20API-4.3-blue.svg?style=flat-square&logo=telegram
|
||||
:target: https://core.telegram.org/bots/api
|
||||
:alt: Telegram Bot API
|
||||
|
||||
.. image:: https://img.shields.io/readthedocs/pip/stable.svg?style=flat-square
|
||||
:target: http://aiogram.readthedocs.io/en/latest/?badge=latest
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue