From 1f30b86ca2a51165ec2510e0cda7360518786ef8 Mon Sep 17 00:00:00 2001 From: thsrite Date: Fri, 26 Apr 2024 11:32:31 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=87=AA=E5=AE=9A=E4=B9=89=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E6=B6=88=E6=81=AF=E5=A4=A9=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 7 +++++-- plugins/invitessignin/__init__.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 127aaf3..d7f14fd 100644 --- a/package.json +++ b/package.json @@ -294,10 +294,13 @@ "InvitesSignin": { "name": "药丸签到", "description": "药丸论坛签到。", - "version": "1.3", + "version": "1.4", "icon": "invites.png", "author": "thsrite", - "level": 2 + "level": 2, + "history": { + "v1.4": "自定义保留消息天数" + } }, "PersonMeta": { "name": "演职人员刮削", diff --git a/plugins/invitessignin/__init__.py b/plugins/invitessignin/__init__.py index 059e3b8..7d56dfb 100644 --- a/plugins/invitessignin/__init__.py +++ b/plugins/invitessignin/__init__.py @@ -1,5 +1,6 @@ import json import re +import time from datetime import datetime, timedelta import pytz @@ -22,7 +23,7 @@ class InvitesSignin(_PluginBase): # 插件图标 plugin_icon = "invites.png" # 插件版本 - plugin_version = "1.3" + plugin_version = "1.4" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -41,6 +42,7 @@ class InvitesSignin(_PluginBase): _cookie = None _onlyonce = False _notify = False + _history_days = None # 定时器 _scheduler: Optional[BackgroundScheduler] = None @@ -55,6 +57,7 @@ class InvitesSignin(_PluginBase): self._cookie = config.get("cookie") self._notify = config.get("notify") self._onlyonce = config.get("onlyonce") + self._history_days = config.get("history_days") or 30 if self._onlyonce: # 定时服务 @@ -71,6 +74,7 @@ class InvitesSignin(_PluginBase): "enabled": self._enabled, "cookie": self._cookie, "notify": self._notify, + "history_days": self._history_days, }) # 启动任务 @@ -159,6 +163,11 @@ class InvitesSignin(_PluginBase): "totalContinuousCheckIn": totalContinuousCheckIn, "money": money }) + + thirty_days_ago = time.time() - int(self._history_days) * 24 * 60 * 60 + history = [record for record in history if + datetime.strptime(record["date"], + '%Y-%m-%d %H:%M:%S').timestamp() >= thirty_days_ago] # 保存签到历史 self.save_data(key="history", value=history) @@ -261,7 +270,7 @@ class InvitesSignin(_PluginBase): 'component': 'VCol', 'props': { 'cols': 12, - 'md': 6 + 'md': 3 }, 'content': [ { @@ -273,6 +282,22 @@ class InvitesSignin(_PluginBase): } ] }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 3 + }, + 'content': [ + { + 'component': 'VTextField', + 'props': { + 'model': 'history_days', + 'label': '保留历史天数' + } + } + ] + }, { 'component': 'VCol', 'props': { @@ -319,6 +344,7 @@ class InvitesSignin(_PluginBase): "onlyonce": False, "notify": False, "cookie": "", + "history_days": 30, "cron": "0 9 * * *" }