mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-08 04:43:00 +08:00
* 🎨 修改 nonebot_bison 目录位置 * auto fix by pre-commit hooks * 🚚 fix frontend build target * 🚚 use soft link * Revert "🚚 use soft link" This reverts commit de21f79d5ae1bd5515b04f42a4138cb25ddf3e62. * 🚚 modify dockerfile --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: felinae98 <731499577@qq.com>
39 lines
938 B
Python
39 lines
938 B
Python
from typing import Literal, Type
|
|
|
|
from httpx import AsyncClient
|
|
|
|
from ..types import Target
|
|
from .http import http_client
|
|
|
|
|
|
class SchedulerConfig:
|
|
|
|
schedule_type: Literal["date", "interval", "cron"]
|
|
schedule_setting: dict
|
|
name: str
|
|
|
|
def __str__(self):
|
|
return f"[{self.name}]-{self.name}-{self.schedule_setting}"
|
|
|
|
def __init__(self):
|
|
self.default_http_client = http_client()
|
|
|
|
async def get_client(self, target: Target) -> AsyncClient:
|
|
return self.default_http_client
|
|
|
|
async def get_query_name_client(self) -> AsyncClient:
|
|
return self.default_http_client
|
|
|
|
|
|
def scheduler(
|
|
schedule_type: Literal["date", "interval", "cron"], schedule_setting: dict
|
|
) -> Type[SchedulerConfig]:
|
|
return type(
|
|
"AnonymousScheduleConfig",
|
|
(SchedulerConfig,),
|
|
{
|
|
"schedule_type": schedule_type,
|
|
"schedule_setting": schedule_setting,
|
|
},
|
|
)
|