mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 18:19:34 +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
|
||||
else:
|
||||
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)
|
||||
API_VERSION = Version(3, 5)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@ class Bot(BaseBot):
|
|||
delattr(self, '_me')
|
||||
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ import logging
|
|||
import time
|
||||
import typing
|
||||
|
||||
from aiogram.dispatcher.middlewares import MiddlewareManager
|
||||
from .filters import CommandsFilter, ContentTypeFilter, ExceptionsFilter, RegexpFilter, USER_STATE, \
|
||||
generate_default_filters
|
||||
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 .webhook import BaseResponse
|
||||
from ..bot import Bot
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class Filter:
|
|||
"""
|
||||
Base class for filters
|
||||
"""
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
return self.check(*args, **kwargs)
|
||||
|
||||
|
|
@ -58,6 +59,7 @@ class AsyncFilter(Filter):
|
|||
"""
|
||||
Base class for asynchronous filters
|
||||
"""
|
||||
|
||||
def __aiter__(self):
|
||||
return None
|
||||
|
||||
|
|
@ -72,6 +74,7 @@ class AnyFilter(AsyncFilter):
|
|||
"""
|
||||
One filter from many
|
||||
"""
|
||||
|
||||
def __init__(self, *filters: callable):
|
||||
self.filters = filters
|
||||
|
||||
|
|
@ -84,6 +87,7 @@ class NotFilter(AsyncFilter):
|
|||
"""
|
||||
Reverse filter
|
||||
"""
|
||||
|
||||
def __init__(self, filter_: callable):
|
||||
self.filter = filter_
|
||||
|
||||
|
|
@ -95,6 +99,7 @@ class CommandsFilter(AsyncFilter):
|
|||
"""
|
||||
Check commands in message
|
||||
"""
|
||||
|
||||
def __init__(self, commands):
|
||||
self.commands = commands
|
||||
|
||||
|
|
@ -118,6 +123,7 @@ class RegexpFilter(Filter):
|
|||
"""
|
||||
Regexp filter for messages
|
||||
"""
|
||||
|
||||
def __init__(self, regexp):
|
||||
self.regexp = re.compile(regexp, flags=re.IGNORECASE | re.MULTILINE)
|
||||
|
||||
|
|
@ -130,6 +136,7 @@ class ContentTypeFilter(Filter):
|
|||
"""
|
||||
Check message content type
|
||||
"""
|
||||
|
||||
def __init__(self, content_types):
|
||||
self.content_types = content_types
|
||||
|
||||
|
|
@ -142,6 +149,7 @@ class CancelFilter(Filter):
|
|||
"""
|
||||
Find cancel in message text
|
||||
"""
|
||||
|
||||
def __init__(self, cancel_set=None):
|
||||
if cancel_set is None:
|
||||
cancel_set = ['/cancel', 'cancel', 'cancel.']
|
||||
|
|
@ -156,6 +164,7 @@ class StateFilter(AsyncFilter):
|
|||
"""
|
||||
Check user state
|
||||
"""
|
||||
|
||||
def __init__(self, dispatcher, state):
|
||||
self.dispatcher = dispatcher
|
||||
self.state = state
|
||||
|
|
@ -182,6 +191,7 @@ class StatesListFilter(StateFilter):
|
|||
"""
|
||||
List of states
|
||||
"""
|
||||
|
||||
async def check(self, obj):
|
||||
chat, user = self.get_target(obj)
|
||||
|
||||
|
|
@ -194,6 +204,7 @@ class ExceptionsFilter(Filter):
|
|||
"""
|
||||
Filter for exceptions
|
||||
"""
|
||||
|
||||
def __init__(self, exception):
|
||||
self.exception = exception
|
||||
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ class ChatActions(helper.Helper):
|
|||
|
||||
@classmethod
|
||||
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)
|
||||
if sleep:
|
||||
await asyncio.sleep(sleep)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import datetime
|
||||
|
||||
from aiogram.utils import helper
|
||||
from . import base
|
||||
from . import fields
|
||||
from .user import User
|
||||
from ..utils import helper
|
||||
|
||||
|
||||
class ChatMember(base.TelegramObject):
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class MediaGroup(base.TelegramObject):
|
|||
"""
|
||||
Helper for sending media group
|
||||
"""
|
||||
|
||||
def __init__(self, medias: typing.Optional[typing.List[typing.Union[InputMedia, typing.Dict]]] = None):
|
||||
super(MediaGroup, self).__init__()
|
||||
self.media = []
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@ class PreCheckoutQuery(base.TelegramObject):
|
|||
def __eq__(self, other):
|
||||
if isinstance(other, type(self)):
|
||||
return other.id == self.id
|
||||
return self.id == other
|
||||
return self.id == other
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue