mirror of
https://github.com/catspace-dev/unicheckbot.git
synced 2024-11-21 21:46:32 +03:00
Sort imports
This commit is contained in:
parent
784cae145d
commit
7a8990bc74
|
@ -1,12 +1,14 @@
|
||||||
|
from asyncio import sleep
|
||||||
|
|
||||||
from aiogram import Bot, Dispatcher, executor
|
from aiogram import Bot, Dispatcher, executor
|
||||||
from aiogram.contrib.fsm_storage.memory import MemoryStorage
|
from aiogram.contrib.fsm_storage.memory import MemoryStorage
|
||||||
from .middlewares import UserMiddleware, WriteCommandMetric, LoggingMiddleware, ThrottlingMiddleware
|
from loguru import logger
|
||||||
from tortoise import Tortoise
|
from tortoise import Tortoise
|
||||||
from tortoise.exceptions import DBConnectionError
|
from tortoise.exceptions import DBConnectionError
|
||||||
from loguru import logger
|
|
||||||
from asyncio import sleep
|
from . import config, handlers
|
||||||
from . import config
|
from .middlewares import (LoggingMiddleware, ThrottlingMiddleware,
|
||||||
from . import handlers
|
UserMiddleware, WriteCommandMetric)
|
||||||
|
|
||||||
storage = MemoryStorage()
|
storage = MemoryStorage()
|
||||||
telegram_bot = Bot(token=config.TELEGRAM_BOT_TOKEN)
|
telegram_bot = Bot(token=config.TELEGRAM_BOT_TOKEN)
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
from aiogram.types import Message
|
|
||||||
from typing import Tuple, Any, List
|
|
||||||
|
|
||||||
from ..nodes import nodes as all_nodes
|
|
||||||
from httpx import Response
|
|
||||||
from aiogram.bot import Bot
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from core.coretypes import APINodeInfo
|
|
||||||
from .helpers import send_api_requests
|
|
||||||
from .errors import NotEnoughArgs, InvalidPort, LocalhostForbidden
|
|
||||||
from .validators import BaseValidator, LocalhostValidator
|
|
||||||
from ..middlewares.throttling import rate_limit
|
|
||||||
from loguru import logger
|
|
||||||
from uuid import uuid4
|
|
||||||
from time import time
|
from time import time
|
||||||
|
from typing import Any, List, Tuple
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
|
from aiogram.bot import Bot
|
||||||
|
from aiogram.types import Message
|
||||||
|
from core.coretypes import APINodeInfo
|
||||||
|
from httpx import Response
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
|
from ..middlewares.throttling import rate_limit
|
||||||
|
from ..nodes import nodes as all_nodes
|
||||||
|
from .errors import InvalidPort, LocalhostForbidden, NotEnoughArgs
|
||||||
|
from .helpers import send_api_requests
|
||||||
|
from .validators import BaseValidator, LocalhostValidator
|
||||||
|
|
||||||
header = "Отчет о проверке хоста:" \
|
header = "Отчет о проверке хоста:" \
|
||||||
"\n\n— Хост: {target_fq}"\
|
"\n\n— Хост: {target_fq}"\
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
from aiogram import Dispatcher
|
from aiogram import Dispatcher
|
||||||
|
|
||||||
|
from .icmp import ICMPCheckerHandler
|
||||||
|
from .ipcalc import IPCalcCommandHandler
|
||||||
|
from .minecraft import MinecraftCheckerHandler
|
||||||
from .start import start_cmd
|
from .start import start_cmd
|
||||||
|
from .tcp import TCPCheckerHandler
|
||||||
from .web import WebCheckerHandler
|
from .web import WebCheckerHandler
|
||||||
from .whois import WhoisCommandHandler
|
from .whois import WhoisCommandHandler
|
||||||
from .icmp import ICMPCheckerHandler
|
|
||||||
from .tcp import TCPCheckerHandler
|
|
||||||
from .minecraft import MinecraftCheckerHandler
|
|
||||||
from .ipcalc import IPCalcCommandHandler
|
|
||||||
|
|
||||||
|
|
||||||
def setup(dp: Dispatcher):
|
def setup(dp: Dispatcher):
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
from aiogram.types import Message
|
from aiogram.types import Message
|
||||||
from httpx import Response
|
|
||||||
from core.coretypes import ErrorPayload, ICMPCheckerResponse, ResponseStatus
|
from core.coretypes import ErrorPayload, ICMPCheckerResponse, ResponseStatus
|
||||||
from ..base import CheckerBaseHandler, NotEnoughArgs, LocalhostForbidden
|
from httpx import Response
|
||||||
from ..metrics import push_status_metric
|
|
||||||
from ...middlewares.throttling import rate_limit
|
from ...middlewares.throttling import rate_limit
|
||||||
|
from ..base import CheckerBaseHandler, LocalhostForbidden, NotEnoughArgs
|
||||||
|
from ..metrics import push_status_metric
|
||||||
|
|
||||||
icmp_help_message = """
|
icmp_help_message = """
|
||||||
❓ Производит проверку хоста по протоколу ICMP.
|
❓ Производит проверку хоста по протоколу ICMP.
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
from aiogram.types import Message
|
|
||||||
from typing import Union
|
|
||||||
import ipaddress
|
import ipaddress
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
from aiogram.types import Message
|
||||||
|
|
||||||
from ..base import SimpleCommandHandler, NotEnoughArgs
|
|
||||||
from ...middlewares.throttling import rate_limit
|
from ...middlewares.throttling import rate_limit
|
||||||
|
from ..base import NotEnoughArgs, SimpleCommandHandler
|
||||||
|
|
||||||
ipcalc_help_message = """
|
ipcalc_help_message = """
|
||||||
❓ Калькулятор IP подсетей.
|
❓ Калькулятор IP подсетей.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from core.coretypes import ResponseStatus, ErrorPayload, MinecraftResponse
|
from core.coretypes import ErrorPayload, MinecraftResponse, ResponseStatus
|
||||||
from httpx import Response
|
from httpx import Response
|
||||||
|
|
||||||
from ..base import CheckerTargetPortHandler, process_args_for_host_port
|
from ..base import CheckerTargetPortHandler, process_args_for_host_port
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
from aiogram.types import Message
|
from aiogram.types import Message
|
||||||
from ...models.user import User
|
|
||||||
from ...middlewares.throttling import rate_limit
|
from ...middlewares.throttling import rate_limit
|
||||||
from ...middlewares.userdata import userdata_required
|
from ...middlewares.userdata import userdata_required
|
||||||
|
from ...models.user import User
|
||||||
|
|
||||||
start_message = """
|
start_message = """
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
from typing import Tuple
|
from typing import Tuple
|
||||||
|
|
||||||
from aiogram.types import Message
|
from aiogram.types import Message
|
||||||
from core.coretypes import ResponseStatus, ErrorPayload, PortResponse
|
from core.coretypes import ErrorPayload, PortResponse, ResponseStatus
|
||||||
from httpx import Response
|
from httpx import Response
|
||||||
|
|
||||||
from ..base import CheckerTargetPortHandler, NotEnoughArgs, InvalidPort, parse_host_port
|
|
||||||
from ..metrics import push_status_metric
|
|
||||||
from ...middlewares.throttling import rate_limit
|
from ...middlewares.throttling import rate_limit
|
||||||
|
from ..base import (CheckerTargetPortHandler, InvalidPort, NotEnoughArgs,
|
||||||
|
parse_host_port)
|
||||||
|
from ..metrics import push_status_metric
|
||||||
|
|
||||||
tcp_help_message = """
|
tcp_help_message = """
|
||||||
❓ Производит проверку TCP порта, открыт ли он или нет
|
❓ Производит проверку TCP порта, открыт ли он или нет
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
|
from core.coretypes import (HTTP_EMOJI, ErrorPayload, HttpCheckerResponse,
|
||||||
|
ResponseStatus)
|
||||||
from httpx import Response
|
from httpx import Response
|
||||||
from core.coretypes import ResponseStatus, HTTP_EMOJI, HttpCheckerResponse, ErrorPayload
|
|
||||||
from ..base import CheckerTargetPortHandler, process_args_for_host_port
|
from ..base import CheckerTargetPortHandler, process_args_for_host_port
|
||||||
from ..metrics import push_status_metric
|
from ..metrics import push_status_metric
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
|
from dataclasses import dataclass
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from whois import whois, parser
|
|
||||||
from aiogram.types import Message
|
from aiogram.types import Message
|
||||||
from dataclasses import dataclass
|
|
||||||
from whois_vu.api import WhoisSource
|
from whois_vu.api import WhoisSource
|
||||||
from whois_vu.errors import IncorrectZone, QueryNotMatchRegexp
|
from whois_vu.errors import IncorrectZone, QueryNotMatchRegexp
|
||||||
|
|
||||||
from ..whois_zones import ZONES
|
from whois import parser, whois
|
||||||
from ..base import SimpleCommandHandler
|
|
||||||
from ..errors import NotEnoughArgs, LocalhostForbidden
|
|
||||||
from ...middlewares.throttling import rate_limit
|
from ...middlewares.throttling import rate_limit
|
||||||
|
from ..base import SimpleCommandHandler
|
||||||
|
from ..errors import LocalhostForbidden, NotEnoughArgs
|
||||||
|
from ..whois_zones import ZONES
|
||||||
|
|
||||||
whois_help_message = """
|
whois_help_message = """
|
||||||
❓ Вернёт информацию о домене.
|
❓ Вернёт информацию о домене.
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
from httpx import AsyncClient, Timeout, Response
|
|
||||||
from typing import List, Callable
|
|
||||||
from core.coretypes import APINode
|
|
||||||
from ipaddress import ip_address
|
|
||||||
from contextlib import suppress
|
|
||||||
from loguru import logger
|
|
||||||
from aiogram.bot import Bot
|
|
||||||
from .metrics import push_api_request_status
|
|
||||||
from ..config import NOTIFICATION_BOT_TOKEN, NOTIFICATION_USERS
|
|
||||||
from traceback import format_exc
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from contextlib import suppress
|
||||||
|
from ipaddress import ip_address
|
||||||
|
from traceback import format_exc
|
||||||
|
from typing import Callable, List
|
||||||
|
|
||||||
|
from aiogram.bot import Bot
|
||||||
|
from core.coretypes import APINode
|
||||||
|
from httpx import AsyncClient, Response, Timeout
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
|
from ..config import NOTIFICATION_BOT_TOKEN, NOTIFICATION_USERS
|
||||||
|
from .metrics import push_api_request_status
|
||||||
|
|
||||||
|
|
||||||
async def send_api_request(client: AsyncClient, endpoint: str, data: dict, node: APINode):
|
async def send_api_request(client: AsyncClient, endpoint: str, data: dict, node: APINode):
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
from aioinflux import InfluxDBClient
|
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from ..config import INFLUX_DB, INFLUX_HOST, INFLUX_PORT, INFLUX_PASSWORD, INFLUX_USERNAME
|
|
||||||
|
from aioinflux import InfluxDBClient
|
||||||
|
|
||||||
|
from ..config import (INFLUX_DB, INFLUX_HOST, INFLUX_PASSWORD, INFLUX_PORT,
|
||||||
|
INFLUX_USERNAME)
|
||||||
|
|
||||||
|
|
||||||
async def push_metric(measurement, tags: Dict, fields: Dict):
|
async def push_metric(measurement, tags: Dict, fields: Dict):
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from .errors import LocalhostForbidden
|
|
||||||
from ipaddress import ip_address
|
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
|
from ipaddress import ip_address
|
||||||
|
|
||||||
|
from .errors import LocalhostForbidden
|
||||||
|
|
||||||
|
|
||||||
class BaseValidator:
|
class BaseValidator:
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from .write_command_metric import WriteCommandMetric
|
|
||||||
from .logging import LoggingMiddleware
|
from .logging import LoggingMiddleware
|
||||||
from .throttling import ThrottlingMiddleware
|
from .throttling import ThrottlingMiddleware
|
||||||
from .userdata import UserMiddleware
|
from .userdata import UserMiddleware
|
||||||
|
from .write_command_metric import WriteCommandMetric
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import asyncio
|
||||||
|
|
||||||
from aiogram import Dispatcher, types
|
from aiogram import Dispatcher, types
|
||||||
from aiogram.dispatcher import DEFAULT_RATE_LIMIT
|
from aiogram.dispatcher import DEFAULT_RATE_LIMIT
|
||||||
from aiogram.dispatcher.handler import CancelHandler, current_handler
|
from aiogram.dispatcher.handler import CancelHandler, current_handler
|
||||||
from aiogram.dispatcher.middlewares import BaseMiddleware
|
from aiogram.dispatcher.middlewares import BaseMiddleware
|
||||||
from aiogram.utils.exceptions import Throttled
|
from aiogram.utils.exceptions import Throttled
|
||||||
import asyncio
|
|
||||||
|
|
||||||
|
|
||||||
def rate_limit(func):
|
def rate_limit(func):
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from aiogram.dispatcher.handler import current_handler
|
from aiogram.dispatcher.handler import current_handler
|
||||||
from aiogram.dispatcher.middlewares import BaseMiddleware
|
from aiogram.dispatcher.middlewares import BaseMiddleware
|
||||||
from aiogram.types import Message, CallbackQuery
|
from aiogram.types import CallbackQuery, Message
|
||||||
|
|
||||||
from ..models import User
|
from ..models import User
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from aiogram.dispatcher.middlewares import BaseMiddleware
|
from aiogram.dispatcher.middlewares import BaseMiddleware
|
||||||
from aiogram.types import Message
|
from aiogram.types import Message
|
||||||
|
|
||||||
from ..handlers.metrics import push_metric
|
from ..handlers.metrics import push_metric
|
||||||
from ..models import User, UserCheckRequests
|
from ..models import User, UserCheckRequests
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from core.coretypes import APINode
|
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
from core.coretypes import APINode
|
||||||
|
|
||||||
nodes: List[APINode] = [
|
nodes: List[APINode] = [
|
||||||
APINode("http://localhost:8080", "CHANGE_TOKEN_BY_ENV"),
|
APINode("http://localhost:8080", "CHANGE_TOKEN_BY_ENV"),
|
||||||
APINode("http://localhost:8080", "CHANGE_TOKEN_BY_ENV"),
|
APINode("http://localhost:8080", "CHANGE_TOKEN_BY_ENV"),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user