Per docs/plugin-audit-report.md (plugins normalized to Trigger(handlers) → Service(services) → Model(repository/models) + utils): - Split monolithic __init__.py into handlers/services/utils across dailywife, deer_pipe, dice, galgame_card, helldivers_tools, huoziyinshua, learning_chat, makeaquote, mc_server_status, ncm_saying, picfinder_take, picstatus, random_jm_code, regif, steam_info, video_analysis, group_tools - Move static assets under res/: deer_pipe font/img, makeaquote font, helldivers img/templates, huoziyinshua HuoZiYinShua - Add config.py + register_config_items to ncm_saying, random_jm_code, group_tools; learning_chat unified config bridge - Remove deprecated: voice_trans plugin, bf_bot/test.py, dead code in dailywife/deer_pipe, empty dirs, debug scripts under helldivers temp - Disable brash_general_supercredits_tools (stub comment only) - bot.py: optional stdout/stderr redirect to log file for Web log viewer, force ANSI colorize on non-TTY sinks - Move runtime data (jm_code.json) out of plugin dir into hexi/data - Docs: plugin-audit-report.md; README reflects removed plugins Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
1.1 KiB
Python
41 lines
1.1 KiB
Python
"""打卡记鹿 —— 数据访问(Model/Repository 层)。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
|
|
from nonebot import require
|
|
|
|
require("nonebot_plugin_orm")
|
|
|
|
from nonebot_plugin_orm import get_session
|
|
from sqlalchemy import select
|
|
|
|
from .models import CheckInRecord
|
|
|
|
|
|
async def record_month(uid):
|
|
now = datetime.now()
|
|
async with get_session() as session:
|
|
session.add(CheckInRecord(uid=int(uid), date=now.date()))
|
|
await session.commit()
|
|
|
|
|
|
async def get_records(uid):
|
|
now = datetime.now()
|
|
month_start = datetime(now.year, now.month, 1).date()
|
|
if now.month == 12:
|
|
month_end = datetime(now.year + 1, 1, 1).date()
|
|
else:
|
|
month_end = datetime(now.year, now.month + 1, 1).date()
|
|
async with get_session() as session:
|
|
result = await session.execute(
|
|
select(CheckInRecord.date).where(
|
|
CheckInRecord.uid == int(uid),
|
|
CheckInRecord.date >= month_start,
|
|
CheckInRecord.date < month_end,
|
|
)
|
|
)
|
|
days = result.all()
|
|
return [row[0].day for row in days]
|