mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2026-06-23 22:16:53 +08:00
update
This commit is contained in:
@@ -136,9 +136,9 @@ def register_router_fastapi(driver: Driver, socketio):
|
||||
async def _get_weight_config():
|
||||
return await get_weight_config()
|
||||
|
||||
@app.patch(WEIGHT_URL, dependencies=[Depends(check_is_superuser)])
|
||||
async def _update_weight_config(platformName: str, target: str, req: WeightConfig):
|
||||
return await update_weigth_config(platformName, target, req)
|
||||
@app.put(WEIGHT_URL, dependencies=[Depends(check_is_superuser)])
|
||||
async def _update_weight_config(platform_name: str, target: str, req: WeightConfig):
|
||||
return await update_weigth_config(platform_name, target, req)
|
||||
|
||||
app.mount(URL_BASE, SinglePageApplication(directory=static_path), name="bison")
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
from pathlib import Path
|
||||
|
||||
import nonebot
|
||||
from alembic.config import Config
|
||||
from alembic.runtime.environment import EnvironmentContext
|
||||
from alembic.script.base import ScriptDirectory
|
||||
from nonebot.log import logger
|
||||
from nonebot_plugin_datastore import PluginData, create_session, db
|
||||
from nonebot_plugin_datastore import PluginData, db
|
||||
from nonebot_plugin_datastore.db import get_engine
|
||||
from sqlalchemy.engine.base import Connection
|
||||
from sqlalchemy.ext.asyncio.session import AsyncSession
|
||||
|
||||
@@ -195,7 +195,10 @@ class DBConfig:
|
||||
raise NoSuchTargetException()
|
||||
target_id = targetObj.id
|
||||
targetObj.default_schedule_weight = conf.default
|
||||
delete(ScheduleTimeWeight).where(ScheduleTimeWeight.target_id == target_id)
|
||||
delete_statement = delete(ScheduleTimeWeight).where(
|
||||
ScheduleTimeWeight.target_id == target_id
|
||||
)
|
||||
await sess.execute(delete_statement)
|
||||
for time_conf in conf.time_config:
|
||||
new_conf = ScheduleTimeWeight(
|
||||
start_time=time_conf.start_time,
|
||||
@@ -271,6 +274,7 @@ class DBConfig:
|
||||
res[platform_name][target.target] = PlatformWeightConfigResp(
|
||||
target=T_Target(target.target),
|
||||
target_name=target.target_name,
|
||||
platform_name=platform_name,
|
||||
weight=WeightConfig(
|
||||
default=target.default_schedule_weight, time_config=[]
|
||||
),
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql.schema import Column, ForeignKey, UniqueConstraint
|
||||
from sqlalchemy.sql.sqltypes import JSON, DateTime, Integer, String, Time
|
||||
from sqlalchemy.sql.sqltypes import JSON, Integer, String, Time
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
from dataclasses import dataclass
|
||||
from datetime import time
|
||||
from typing import Any, Callable, Literal, NamedTuple, NewType
|
||||
from typing import Any, Literal, NamedTuple, NewType
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
RawPost = NewType("RawPost", Any)
|
||||
Target = NewType("Target", str)
|
||||
@@ -27,22 +29,19 @@ class UserSubInfo(NamedTuple):
|
||||
tags: list[Tag]
|
||||
|
||||
|
||||
@dataclass
|
||||
class TimeWeightConfig:
|
||||
class TimeWeightConfig(BaseModel):
|
||||
start_time: time
|
||||
end_time: time
|
||||
weight: int
|
||||
|
||||
|
||||
@dataclass
|
||||
class WeightConfig:
|
||||
|
||||
class WeightConfig(BaseModel):
|
||||
default: int
|
||||
time_config: list[TimeWeightConfig]
|
||||
|
||||
|
||||
@dataclass
|
||||
class PlatformWeightConfigResp:
|
||||
class PlatformWeightConfigResp(BaseModel):
|
||||
target: Target
|
||||
target_name: str
|
||||
platform_name: str
|
||||
weight: WeightConfig
|
||||
|
||||
Reference in New Issue
Block a user