mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-14 02:52:12 +00:00
Relative imports and reformat code (auto)
This commit is contained in:
parent
6a64573e44
commit
0295aed615
8 changed files with 19 additions and 6 deletions
|
|
@ -16,8 +16,8 @@ except ImportError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
import asyncio
|
import asyncio
|
||||||
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
|
||||||
|
|
||||||
|
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
|
||||||
|
|
||||||
VERSION = Version(1, 0, 3, stage=Stage.DEV, build=0)
|
VERSION = Version(1, 0, 3, stage=Stage.DEV, build=0)
|
||||||
API_VERSION = Version(3, 5)
|
API_VERSION = Version(3, 5)
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,8 @@ class Bot(BaseBot):
|
||||||
delattr(self, '_me')
|
delattr(self, '_me')
|
||||||
|
|
||||||
async def download_file_by_id(self, file_id: base.String, destination=None,
|
async def download_file_by_id(self, file_id: base.String, destination=None,
|
||||||
timeout: base.Integer=30, chunk_size: base.Integer=65536, seek: base.Boolean=True):
|
timeout: base.Integer = 30, chunk_size: base.Integer = 65536,
|
||||||
|
seek: base.Boolean = True):
|
||||||
"""
|
"""
|
||||||
Download file by file_id to destination
|
Download file by file_id to destination
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@ import logging
|
||||||
import time
|
import time
|
||||||
import typing
|
import typing
|
||||||
|
|
||||||
from aiogram.dispatcher.middlewares import MiddlewareManager
|
|
||||||
from .filters import CommandsFilter, ContentTypeFilter, ExceptionsFilter, RegexpFilter, USER_STATE, \
|
from .filters import CommandsFilter, ContentTypeFilter, ExceptionsFilter, RegexpFilter, USER_STATE, \
|
||||||
generate_default_filters
|
generate_default_filters
|
||||||
from .handler import CancelHandler, Handler, SkipHandler
|
from .handler import CancelHandler, Handler, SkipHandler
|
||||||
|
from .middlewares import MiddlewareManager
|
||||||
from .storage import BaseStorage, DELTA, DisabledStorage, EXCEEDED_COUNT, FSMContext, LAST_CALL, RATE_LIMIT, RESULT
|
from .storage import BaseStorage, DELTA, DisabledStorage, EXCEEDED_COUNT, FSMContext, LAST_CALL, RATE_LIMIT, RESULT
|
||||||
from .webhook import BaseResponse
|
from .webhook import BaseResponse
|
||||||
from ..bot import Bot
|
from ..bot import Bot
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ class Filter:
|
||||||
"""
|
"""
|
||||||
Base class for filters
|
Base class for filters
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __call__(self, *args, **kwargs):
|
def __call__(self, *args, **kwargs):
|
||||||
return self.check(*args, **kwargs)
|
return self.check(*args, **kwargs)
|
||||||
|
|
||||||
|
|
@ -58,6 +59,7 @@ class AsyncFilter(Filter):
|
||||||
"""
|
"""
|
||||||
Base class for asynchronous filters
|
Base class for asynchronous filters
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __aiter__(self):
|
def __aiter__(self):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
@ -72,6 +74,7 @@ class AnyFilter(AsyncFilter):
|
||||||
"""
|
"""
|
||||||
One filter from many
|
One filter from many
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, *filters: callable):
|
def __init__(self, *filters: callable):
|
||||||
self.filters = filters
|
self.filters = filters
|
||||||
|
|
||||||
|
|
@ -84,6 +87,7 @@ class NotFilter(AsyncFilter):
|
||||||
"""
|
"""
|
||||||
Reverse filter
|
Reverse filter
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, filter_: callable):
|
def __init__(self, filter_: callable):
|
||||||
self.filter = filter_
|
self.filter = filter_
|
||||||
|
|
||||||
|
|
@ -95,6 +99,7 @@ class CommandsFilter(AsyncFilter):
|
||||||
"""
|
"""
|
||||||
Check commands in message
|
Check commands in message
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, commands):
|
def __init__(self, commands):
|
||||||
self.commands = commands
|
self.commands = commands
|
||||||
|
|
||||||
|
|
@ -118,6 +123,7 @@ class RegexpFilter(Filter):
|
||||||
"""
|
"""
|
||||||
Regexp filter for messages
|
Regexp filter for messages
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, regexp):
|
def __init__(self, regexp):
|
||||||
self.regexp = re.compile(regexp, flags=re.IGNORECASE | re.MULTILINE)
|
self.regexp = re.compile(regexp, flags=re.IGNORECASE | re.MULTILINE)
|
||||||
|
|
||||||
|
|
@ -130,6 +136,7 @@ class ContentTypeFilter(Filter):
|
||||||
"""
|
"""
|
||||||
Check message content type
|
Check message content type
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, content_types):
|
def __init__(self, content_types):
|
||||||
self.content_types = content_types
|
self.content_types = content_types
|
||||||
|
|
||||||
|
|
@ -142,6 +149,7 @@ class CancelFilter(Filter):
|
||||||
"""
|
"""
|
||||||
Find cancel in message text
|
Find cancel in message text
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, cancel_set=None):
|
def __init__(self, cancel_set=None):
|
||||||
if cancel_set is None:
|
if cancel_set is None:
|
||||||
cancel_set = ['/cancel', 'cancel', 'cancel.']
|
cancel_set = ['/cancel', 'cancel', 'cancel.']
|
||||||
|
|
@ -156,6 +164,7 @@ class StateFilter(AsyncFilter):
|
||||||
"""
|
"""
|
||||||
Check user state
|
Check user state
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, dispatcher, state):
|
def __init__(self, dispatcher, state):
|
||||||
self.dispatcher = dispatcher
|
self.dispatcher = dispatcher
|
||||||
self.state = state
|
self.state = state
|
||||||
|
|
@ -182,6 +191,7 @@ class StatesListFilter(StateFilter):
|
||||||
"""
|
"""
|
||||||
List of states
|
List of states
|
||||||
"""
|
"""
|
||||||
|
|
||||||
async def check(self, obj):
|
async def check(self, obj):
|
||||||
chat, user = self.get_target(obj)
|
chat, user = self.get_target(obj)
|
||||||
|
|
||||||
|
|
@ -194,6 +204,7 @@ class ExceptionsFilter(Filter):
|
||||||
"""
|
"""
|
||||||
Filter for exceptions
|
Filter for exceptions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, exception):
|
def __init__(self, exception):
|
||||||
self.exception = exception
|
self.exception = exception
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -211,7 +211,7 @@ class ChatActions(helper.Helper):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def _do(cls, action: str, sleep=None):
|
async def _do(cls, action: str, sleep=None):
|
||||||
from aiogram.dispatcher.ctx import get_bot, get_chat
|
from ..dispatcher.ctx import get_bot, get_chat
|
||||||
await get_bot().send_chat_action(get_chat(), action)
|
await get_bot().send_chat_action(get_chat(), action)
|
||||||
if sleep:
|
if sleep:
|
||||||
await asyncio.sleep(sleep)
|
await asyncio.sleep(sleep)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import datetime
|
import datetime
|
||||||
|
|
||||||
from aiogram.utils import helper
|
|
||||||
from . import base
|
from . import base
|
||||||
from . import fields
|
from . import fields
|
||||||
from .user import User
|
from .user import User
|
||||||
|
from ..utils import helper
|
||||||
|
|
||||||
|
|
||||||
class ChatMember(base.TelegramObject):
|
class ChatMember(base.TelegramObject):
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,7 @@ class MediaGroup(base.TelegramObject):
|
||||||
"""
|
"""
|
||||||
Helper for sending media group
|
Helper for sending media group
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, medias: typing.Optional[typing.List[typing.Union[InputMedia, typing.Dict]]] = None):
|
def __init__(self, medias: typing.Optional[typing.List[typing.Union[InputMedia, typing.Dict]]] = None):
|
||||||
super(MediaGroup, self).__init__()
|
super(MediaGroup, self).__init__()
|
||||||
self.media = []
|
self.media = []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue