Merge remote-tracking branch 'upstream/dev-1.x' into dev-1.x

This commit is contained in:
Suren Khorenyan 2018-02-11 12:50:44 +03:00
commit bd8e1473c0
12 changed files with 35 additions and 19 deletions

View file

@ -20,7 +20,7 @@ else:
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
VERSION = Version(1, 0, 5, stage=Stage.DEV, build=0) VERSION = Version(1, 1, 0, stage=Stage.FINAL, build=0)
API_VERSION = Version(3, 5) API_VERSION = Version(3, 5)
__version__ = VERSION.version __version__ = VERSION.version

View file

@ -907,7 +907,7 @@ class Bot(BaseBot):
async def export_chat_invite_link(self, chat_id: typing.Union[base.Integer, base.String]) -> base.String: async def export_chat_invite_link(self, chat_id: typing.Union[base.Integer, base.String]) -> base.String:
""" """
Use this method to export an invite link to a supergroup or a channel. Use this method to generate a new invite link for a chat; any previously generated link is revoked.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://core.telegram.org/bots/api#exportchatinvitelink Source: https://core.telegram.org/bots/api#exportchatinvitelink

View file

@ -444,8 +444,6 @@ class Dispatcher:
:param kwargs: :param kwargs:
:return: decorated function :return: decorated function
""" """
if commands is None:
commands = []
if content_types is None: if content_types is None:
content_types = ContentType.TEXT content_types = ContentType.TEXT
if custom_filters is None: if custom_filters is None:
@ -509,8 +507,6 @@ class Dispatcher:
:param kwargs: :param kwargs:
:return: decorated function :return: decorated function
""" """
if commands is None:
commands = []
if content_types is None: if content_types is None:
content_types = ContentType.TEXT content_types = ContentType.TEXT
if custom_filters is None: if custom_filters is None:
@ -566,8 +562,6 @@ class Dispatcher:
:param kwargs: :param kwargs:
:return: decorated function :return: decorated function
""" """
if commands is None:
commands = []
if content_types is None: if content_types is None:
content_types = ContentType.TEXT content_types = ContentType.TEXT
if custom_filters is None: if custom_filters is None:

View file

@ -100,6 +100,8 @@ class Message(base.TelegramObject):
return ContentType.VENUE[0] return ContentType.VENUE[0]
if self.new_chat_members: if self.new_chat_members:
return ContentType.NEW_CHAT_MEMBERS[0] return ContentType.NEW_CHAT_MEMBERS[0]
if self.left_chat_member:
return ContentType.LEFT_CHAT_MEMBER[0]
if self.invoice: if self.invoice:
return ContentType.INVOICE[0] return ContentType.INVOICE[0]
if self.successful_payment: if self.successful_payment:
@ -655,6 +657,7 @@ class ContentType(helper.Helper):
:key: LOCATION :key: LOCATION
:key: VENUE :key: VENUE
:key: NEW_CHAT_MEMBERS :key: NEW_CHAT_MEMBERS
:key: LEFT_CHAT_MEMBER
:key: INVOICE :key: INVOICE
:key: SUCCESSFUL_PAYMENT :key: SUCCESSFUL_PAYMENT
""" """
@ -673,6 +676,7 @@ class ContentType(helper.Helper):
LOCATION = helper.ListItem() # location LOCATION = helper.ListItem() # location
VENUE = helper.ListItem() # venue VENUE = helper.ListItem() # venue
NEW_CHAT_MEMBERS = helper.ListItem() # new_chat_member NEW_CHAT_MEMBERS = helper.ListItem() # new_chat_member
LEFT_CHAT_MEMBER = helper.ListItem() # left_chat_member
INVOICE = helper.ListItem() # invoice INVOICE = helper.ListItem() # invoice
SUCCESSFUL_PAYMENT = helper.ListItem() # successful_payment SUCCESSFUL_PAYMENT = helper.ListItem() # successful_payment

View file

@ -69,7 +69,7 @@ class User(base.TelegramObject):
as_html = True as_html = True
if name is None: if name is None:
name = self.mention name = self.full_name
if as_html: if as_html:
return markdown.hlink(name, self.url) return markdown.hlink(name, self.url)
return markdown.link(name, self.url) return markdown.link(name, self.url)

View file

@ -3,9 +3,6 @@ Data types
Bases Bases
----- -----
:class:`aiogram.types.base.Serializable`
:class:`aiogram.types.base.Deserializable`
.. automodule:: aiogram.types.base .. automodule:: aiogram.types.base
:members: :members:
@ -210,6 +207,16 @@ ResponseParameters
:members: :members:
:show-inheritance: :show-inheritance:
InputMedia
----------
:class:`aiogram.types.InputMediaPhoto`
:class:`aiogram.types.InputMediaVideo`
:class:`aiogram.types.MediaGroup`
.. automodule:: aiogram.types.input_media
:members:
:show-inheritance:
Sticker Sticker
------- -------
:class:`aiogram.types.Sticker` :class:`aiogram.types.Sticker`
@ -299,3 +306,13 @@ Games
.. automodule:: aiogram.types.game_high_score .. automodule:: aiogram.types.game_high_score
:members: :members:
:show-inheritance: :show-inheritance:
InputFile interface
-------------------
:class:`aiogram.types.InputFile`
.. automodule:: aiogram.types.input_file
:members:
:show-inheritance:

View file

@ -39,7 +39,7 @@ install_requires = get_requirements()
setup( setup(
name='aiogram', name='aiogram',
version=VERSION.version, version=VERSION.version,
packages=PackageFinder.find(exclude=('tests', 'examples', 'docs',)), packages=PackageFinder.find(exclude=('tests', 'tests.*', 'examples.*', 'docs',)),
url='https://github.com/aiogram/aiogram', url='https://github.com/aiogram/aiogram',
license='MIT', license='MIT',
author='Alex Root Junior', author='Alex Root Junior',

View file

@ -13,7 +13,7 @@ def test_export():
def test_id(): def test_id():
assert isinstance(chat.id, int) assert isinstance(chat.id, int)
assert chat.id == CHAT['id'] assert chat.id == CHAT['id']
assert hash(chat) == CHAT['id'] # assert hash(chat) == CHAT['id']
def test_name(): def test_name():

View file

@ -3,6 +3,7 @@ from .dataset import GAME
game = types.Game(**GAME) game = types.Game(**GAME)
def test_export(): def test_export():
exported = game.to_python() exported = game.to_python()
assert isinstance(exported, dict) assert isinstance(exported, dict)

View file

@ -13,7 +13,7 @@ def test_export():
def test_message_id(): def test_message_id():
assert hash(message) == MESSAGE['message_id'] # assert hash(message) == MESSAGE['message_id']
assert message.message_id == MESSAGE['message_id'] assert message.message_id == MESSAGE['message_id']
assert message['message_id'] == MESSAGE['message_id'] assert message['message_id'] == MESSAGE['message_id']

View file

@ -12,7 +12,7 @@ def test_export():
def test_update_id(): def test_update_id():
assert isinstance(update.update_id, int) assert isinstance(update.update_id, int)
assert hash(update) == UPDATE['update_id'] # assert hash(update) == UPDATE['update_id']
assert update.update_id == UPDATE['update_id'] assert update.update_id == UPDATE['update_id']

View file

@ -15,7 +15,7 @@ def test_export():
def test_id(): def test_id():
assert isinstance(user.id, int) assert isinstance(user.id, int)
assert user.id == USER['id'] assert user.id == USER['id']
assert hash(user) == USER['id'] # assert hash(user) == USER['id']
def test_bot(): def test_bot():
@ -40,7 +40,7 @@ def test_full_name():
def test_mention(): def test_mention():
assert user.mention == f"@{USER['username']}" assert user.mention == f"@{USER['username']}"
assert user.get_mention('foo') == f"[foo](tg://user?id={USER['id']})" assert user.get_mention('foo', as_html=False) == f"[foo](tg://user?id={USER['id']})"
assert user.get_mention('foo', as_html=True) == f"<a href=\"tg://user?id={USER['id']}\">foo</a>" assert user.get_mention('foo', as_html=True) == f"<a href=\"tg://user?id={USER['id']}\">foo</a>"