from collections.abc import Awaitable, Callable
from functools import wraps
from typing import Concatenate, ParamSpec, TypeVar
from aiohttp import web
Params = ParamSpec("Params")
Request = TypeVar("Request", bound=web.Request)
Response = TypeVar("Response", bound=web.StreamResponse)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
from collections import defaultdict | |
from collections.abc import AsyncIterator, Hashable | |
from contextlib import asynccontextmanager | |
from typing import Self | |
class IDLock: | |
"""Asyncio Lock synced to some id.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
import logging | |
from functools import wraps | |
from typing import Callable, TYPE_CHECKING | |
if TYPE_CHECKING: | |
from aiohttp import web | |
logger = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from typing import TYPE_CHECKING, TypeVar | |
if TYPE_CHECKING: | |
from collections.abc import AsyncIterator | |
T = TypeVar("T") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from traceback import TracebackException | |
from aiohttp import web | |
from aiohttp.abc import StreamResponse | |
from aiohttp.typedefs import Handler | |
from aiohttp.web_exceptions import HTTPException | |
logger = logging.getLogger(__name__) | |
routes = web.RouteTableDef() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
from typing import Any, Awaitable, Callable, Dict, Optional, TypeVar | |
from aiogram import BaseMiddleware | |
from aiogram.dispatcher.flags import get_flag | |
from aiogram.types import CallbackQuery, Message | |
from redis.asyncio import Redis | |
DEFAULT_PREFIX = "throttle" | |
DEFAULT_TTL = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import logging | |
from typing import Awaitable, Callable, Optional | |
from aiogram import Bot | |
from aiogram.client.session.middlewares.base import ( | |
BaseRequestMiddleware, | |
NextRequestMiddlewareType, | |
) | |
from aiogram.exceptions import TelegramRetryAfter |
Can't understand the meaning of returned exception USER_BANNED_IN_CHANNEL
on sending chatAction
to the supergroup
while @TrueMafiaBot
(id: 468253535
) is a member
of that supergroup (e.g. -1001639443192
) and has all required permissions.
Looks like a #bug. I know about 3000 groups with similar bot behaviour.
I tell my users to give admin permissions to the bot - it helps to avoid described behaviour.
Override the entrypoint in docker-compose.yml for the MariaDB Docker container by adding:
entrypoint: mysqld_safe --skip-grant-tables --user=mysql
The start up the Docker Compose stack:
$> docker-compose up -d
Then login to the Docker container:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# _() - is a i18n translator function | |
FULL_MINUTE = 60 | |
FULL_HOUR = 60 * FULL_MINUTE | |
FULL_DAY = 24 * FULL_HOUR | |
HIDE_SECONDS_AFTER_MIN = 3 | |
def time_to_text(seconds: int | float) -> str: | |
"""Receive total seconds and return text quantity of days, hours, minutes and seconds.""" |