mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-16 12:07:13 +00:00
Merge branch 'dev-1.x'
# Conflicts: # aiogram/__init__.py
This commit is contained in:
commit
1e03e6f80a
4 changed files with 26 additions and 8 deletions
|
|
@ -20,7 +20,7 @@ else:
|
||||||
|
|
||||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||||
|
|
||||||
VERSION = Version(1, 2, 2, stage=Stage.FINAL, build=0)
|
VERSION = Version(1, 2, 3, stage=Stage.FINAL, build=0)
|
||||||
API_VERSION = Version(3, 6)
|
API_VERSION = Version(3, 6)
|
||||||
|
|
||||||
__version__ = VERSION.version
|
__version__ = VERSION.version
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ async def _check_result(method_name, response):
|
||||||
|
|
||||||
description = result_json.get('description') or body
|
description = result_json.get('description') or body
|
||||||
|
|
||||||
|
# TODO: refactor the detection of error types
|
||||||
if HTTPStatus.OK <= response.status <= HTTPStatus.IM_USED:
|
if HTTPStatus.OK <= response.status <= HTTPStatus.IM_USED:
|
||||||
return result_json.get('result')
|
return result_json.get('result')
|
||||||
elif 'retry_after' in result_json:
|
elif 'retry_after' in result_json:
|
||||||
|
|
@ -93,23 +94,27 @@ async def _check_result(method_name, response):
|
||||||
exceptions.CantParseUrl.throw()
|
exceptions.CantParseUrl.throw()
|
||||||
elif exceptions.PhotoAsInputFileRequired.check(description):
|
elif exceptions.PhotoAsInputFileRequired.check(description):
|
||||||
exceptions.PhotoAsInputFileRequired.throw()
|
exceptions.PhotoAsInputFileRequired.throw()
|
||||||
|
elif exceptions.ToMuchMessages.check(description):
|
||||||
|
exceptions.ToMuchMessages.throw()
|
||||||
raise exceptions.BadRequest(description)
|
raise exceptions.BadRequest(description)
|
||||||
elif response.status == HTTPStatus.NOT_FOUND:
|
elif response.status == HTTPStatus.NOT_FOUND:
|
||||||
if exceptions.MethodNotKnown.check(description):
|
if exceptions.MethodNotKnown.check(description):
|
||||||
exceptions.MethodNotKnown.throw()
|
exceptions.MethodNotKnown.throw()
|
||||||
raise exceptions.NotFound(description)
|
raise exceptions.NotFound(description)
|
||||||
elif response.status == HTTPStatus.CONFLICT:
|
elif response.status == HTTPStatus.CONFLICT:
|
||||||
if exceptions.TerminatedByOtherGetUpdates.match(description):
|
if exceptions.TerminatedByOtherGetUpdates.check(description):
|
||||||
exceptions.TerminatedByOtherGetUpdates.throw()
|
exceptions.TerminatedByOtherGetUpdates.throw()
|
||||||
if exceptions.CantGetUpdates.match(description):
|
if exceptions.CantGetUpdates.check(description):
|
||||||
exceptions.CantGetUpdates.throw()
|
exceptions.CantGetUpdates.throw()
|
||||||
raise exceptions.ConflictError(description)
|
raise exceptions.ConflictError(description)
|
||||||
elif response.status in [HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN]:
|
elif response.status in [HTTPStatus.UNAUTHORIZED, HTTPStatus.FORBIDDEN]:
|
||||||
if exceptions.BotKicked.match(description):
|
if exceptions.BotKicked.check(description):
|
||||||
exceptions.BotKicked.throw()
|
exceptions.BotKicked.throw()
|
||||||
elif exceptions.BotBlocked.match(description):
|
elif exceptions.BotBlocked.check(description):
|
||||||
exceptions.BotBlocked.throw()
|
exceptions.BotBlocked.throw()
|
||||||
elif exceptions.UserDeactivated.match(description):
|
elif exceptions.UserDeactivated.check(description):
|
||||||
|
exceptions.UserDeactivated.throw()
|
||||||
|
elif exceptions.CantInitiateConversation.check(description):
|
||||||
exceptions.UserDeactivated.throw()
|
exceptions.UserDeactivated.throw()
|
||||||
raise exceptions.Unauthorized(description)
|
raise exceptions.Unauthorized(description)
|
||||||
elif response.status == HTTPStatus.REQUEST_ENTITY_TOO_LARGE:
|
elif response.status == HTTPStatus.REQUEST_ENTITY_TOO_LARGE:
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ TelegramAPIError
|
||||||
NotFound
|
NotFound
|
||||||
MethodNotKnown
|
MethodNotKnown
|
||||||
PhotoAsInputFileRequired
|
PhotoAsInputFileRequired
|
||||||
|
ToMuchMessages
|
||||||
ConflictError
|
ConflictError
|
||||||
TerminatedByOtherGetUpdates
|
TerminatedByOtherGetUpdates
|
||||||
CantGetUpdates
|
CantGetUpdates
|
||||||
|
|
@ -28,6 +29,7 @@ TelegramAPIError
|
||||||
BotKicked
|
BotKicked
|
||||||
BotBlocked
|
BotBlocked
|
||||||
UserDeactivated
|
UserDeactivated
|
||||||
|
CantInitiateConversation
|
||||||
NetworkError
|
NetworkError
|
||||||
RetryAfter
|
RetryAfter
|
||||||
MigrateToChat
|
MigrateToChat
|
||||||
|
|
@ -147,6 +149,13 @@ class PhotoAsInputFileRequired(BadRequest, _MatchErrorMixin):
|
||||||
match = 'Photo should be uploaded as an InputFile'
|
match = 'Photo should be uploaded as an InputFile'
|
||||||
|
|
||||||
|
|
||||||
|
class ToMuchMessages(BadRequest, _MatchErrorMixin):
|
||||||
|
"""
|
||||||
|
Will be raised when you try to send media group with more than 10 items.
|
||||||
|
"""
|
||||||
|
match = 'Too much messages to send as an album'
|
||||||
|
|
||||||
|
|
||||||
class BadWebhook(BadRequest):
|
class BadWebhook(BadRequest):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
@ -203,6 +212,10 @@ class UserDeactivated(Unauthorized, _MatchErrorMixin):
|
||||||
match = 'user is deactivated'
|
match = 'user is deactivated'
|
||||||
|
|
||||||
|
|
||||||
|
class CantInitiateConversation(Unauthorized, _MatchErrorMixin):
|
||||||
|
match = 'bot can\'t initiate conversation with a user'
|
||||||
|
|
||||||
|
|
||||||
class NetworkError(TelegramAPIError):
|
class NetworkError(TelegramAPIError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
4
setup.py
4
setup.py
|
|
@ -1,11 +1,10 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from distutils.core import setup
|
|
||||||
from warnings import warn
|
from warnings import warn
|
||||||
|
|
||||||
from pip.req import parse_requirements
|
from pip.req import parse_requirements
|
||||||
from setuptools import PackageFinder
|
from setuptools import PackageFinder, setup
|
||||||
|
|
||||||
from aiogram import Stage, VERSION
|
from aiogram import Stage, VERSION
|
||||||
|
|
||||||
|
|
@ -47,6 +46,7 @@ setup(
|
||||||
name='aiogram',
|
name='aiogram',
|
||||||
version=VERSION.version,
|
version=VERSION.version,
|
||||||
packages=PackageFinder.find(exclude=('tests', 'tests.*', 'examples.*', 'docs',)),
|
packages=PackageFinder.find(exclude=('tests', 'tests.*', 'examples.*', 'docs',)),
|
||||||
|
requires_python='>=3.6',
|
||||||
url='https://github.com/aiogram/aiogram',
|
url='https://github.com/aiogram/aiogram',
|
||||||
license='MIT',
|
license='MIT',
|
||||||
author='Alex Root Junior',
|
author='Alex Root Junior',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue