mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-25 09:37:30 +00:00
✨ Support refresh all history command
This commit is contained in:
parent
1b054b439c
commit
84682e7fae
@ -81,6 +81,7 @@ class SetCommandPlugin(Plugin):
|
||||
BotCommand("save_entry", "保存条目数据"),
|
||||
BotCommand("remove_all_entry", "删除全部条目数据"),
|
||||
BotCommand("sign_all", "全部账号重新签到"),
|
||||
BotCommand("refresh_all_history", "全部账号刷新历史记录"),
|
||||
BotCommand("send_log", "发送日志"),
|
||||
BotCommand("update", "更新"),
|
||||
BotCommand("set_command", "重设命令"),
|
||||
|
@ -13,6 +13,7 @@ from telegram.error import BadRequest, Forbidden
|
||||
from core.plugin import Plugin, job
|
||||
from core.services.history_data.services import HistoryDataAbyssServices, HistoryDataLedgerServices
|
||||
from gram_core.basemodel import RegionEnum
|
||||
from gram_core.plugin import handler
|
||||
from gram_core.services.cookies import CookiesService
|
||||
from gram_core.services.cookies.models import CookiesStatusEnum
|
||||
from plugins.genshin.abyss import AbyssPlugin
|
||||
@ -21,6 +22,7 @@ from plugins.tools.genshin import GenshinHelper, PlayerNotFoundError, CookiesNot
|
||||
from utils.log import logger
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from telegram import Update
|
||||
from telegram.ext import ContextTypes
|
||||
|
||||
from simnet import GenshinClient
|
||||
@ -99,6 +101,15 @@ class RefreshHistoryJob(Plugin):
|
||||
notice_text = NOTICE_TEXT % ("旅行札记历史记录", now, uid, "旅行札记历史记录")
|
||||
await self.send_notice(context, user_id, notice_text)
|
||||
|
||||
@handler.command(command="refresh_all_history", block=False, admin=True)
|
||||
async def refresh_all_history(self, update: "Update", context: "ContextTypes.DEFAULT_TYPE"):
|
||||
user = update.effective_user
|
||||
logger.info("用户 %s[%s] refresh_all_history 命令请求", user.full_name, user.id)
|
||||
message = update.effective_message
|
||||
reply = await message.reply_text("正在执行刷新历史记录任务,请稍后...")
|
||||
await self.daily_refresh_history(context)
|
||||
await reply.edit_text("全部账号刷新历史记录任务完成")
|
||||
|
||||
@job.run_daily(time=datetime.time(hour=6, minute=1, second=0), name="RefreshHistoryJob")
|
||||
async def daily_refresh_history(self, context: "ContextTypes.DEFAULT_TYPE"):
|
||||
logger.info("正在执行每日刷新历史记录任务")
|
||||
|
Loading…
Reference in New Issue
Block a user