diff --git a/README.md b/README.md index 639a6ff9..9f977023 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![PyPi status](https://img.shields.io/pypi/status/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) [![Downloads](https://img.shields.io/pypi/dm/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) [![Supported python versions](https://img.shields.io/pypi/pyversions/aiogram.svg?style=flat-square)](https://pypi.python.org/pypi/aiogram) +[![Telegram Bot API](https://img.shields.io/badge/Telegram%20Bot%20API-4.3-blue.svg?style=flat-square&logo=telegram)](https://core.telegram.org/bots/api) [![Documentation Status](https://img.shields.io/readthedocs/pip/stable.svg?style=flat-square)](http://aiogram.readthedocs.io/en/latest/?badge=latest) [![Github issues](https://img.shields.io/github/issues/aiogram/aiogram.svg?style=flat-square)](https://github.com/aiogram/aiogram/issues) [![MIT License](https://img.shields.io/pypi/l/aiogram.svg?style=flat-square)](https://opensource.org/licenses/MIT) diff --git a/README.rst b/README.rst index fde5bc7f..0377aad9 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/aiogram/__init__.py b/aiogram/__init__.py index b5e647c9..6fe7d1c6 100644 --- a/aiogram/__init__.py +++ b/aiogram/__init__.py @@ -38,5 +38,5 @@ __all__ = [ 'utils' ] -__version__ = '2.1.1.dev1' -__api_version__ = '4.2' +__version__ = '2.2.dev1' +__api_version__ = '4.3' diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 60dbc36a..6c51b295 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -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 diff --git a/aiogram/types/__init__.py b/aiogram/types/__init__.py index e509ee74..5395e486 100644 --- a/aiogram/types/__init__.py +++ b/aiogram/types/__init__.py @@ -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', diff --git a/aiogram/types/inline_keyboard.py b/aiogram/types/inline_keyboard.py index 69049345..97ad35da 100644 --- a/aiogram/types/inline_keyboard.py +++ b/aiogram/types/inline_keyboard.py @@ -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) diff --git a/aiogram/types/login_url.py b/aiogram/types/login_url.py new file mode 100644 index 00000000..c0dd6133 --- /dev/null +++ b/aiogram/types/login_url.py @@ -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 + ) diff --git a/aiogram/types/message.py b/aiogram/types/message.py index cc392749..2c1f31c8 100644 --- a/aiogram/types/message.py +++ b/aiogram/types/message.py @@ -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() diff --git a/aiogram/utils/exceptions.py b/aiogram/utils/exceptions.py index b817e4cc..45277206 100644 --- a/aiogram/utils/exceptions.py +++ b/aiogram/utils/exceptions.py @@ -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 diff --git a/docs/source/index.rst b/docs/source/index.rst index d9ad1ca4..89cdbf79 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -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