✨ Compatible with pydantic 2.0 using the pydantic compatibility layer provided by nonebot

This commit is contained in:
HibiKier
2025-01-10 12:19:11 +08:00
committed by BalconyJH
parent 23ef00d01f
commit e814469b75
69 changed files with 178 additions and 147 deletions
@@ -37,7 +37,7 @@ class BotLive:
self._data = {}
def add(self, bot_id: str):
self._data[bot_id] = time.time()
self._data[bot_id] = int(time.time())
def get(self, bot_id: str) -> int | None:
return self._data.get(bot_id)
@@ -154,7 +154,7 @@ class ApiDataSource:
for bot in bot_list:
bot.bot = None # type: ignore
select_bot.is_select = True
return [BaseInfo(**e.dict()) for e in bot_list]
return [BaseInfo(**e.to_dict()) for e in bot_list]
@classmethod
async def get_all_chat_count(cls, bot_id: str | None) -> QueryCount:
@@ -1,6 +1,7 @@
from typing import Any
from nonebot.adapters import Bot
from nonebot.compat import model_dump
from nonebot.config import Config
from pydantic import BaseModel
@@ -86,6 +87,9 @@ class BaseInfo(BaseModel):
class Config:
arbitrary_types_allowed = True
def to_dict(self, **kwargs):
return model_dump(self, **kwargs)
class TemplateBaseInfo(BaseInfo):
"""