From 0997691b237aea3e870c3eb266e24461844573fd Mon Sep 17 00:00:00 2001 From: thsrite Date: Fri, 8 Sep 2023 13:06:40 +0800 Subject: [PATCH 1/2] fix time format --- app/plugins/messageforward/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/plugins/messageforward/__init__.py b/app/plugins/messageforward/__init__.py index e0bc2c7e..214a793d 100644 --- a/app/plugins/messageforward/__init__.py +++ b/app/plugins/messageforward/__init__.py @@ -220,10 +220,12 @@ class MessageForward(_PluginBase): access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid, appsecret=appsecret) if access_token: + if isinstance(access_token_time, datetime): + access_token_time = access_token_time.strftime('%Y-%m-%d %H:%M:%S') wechat_token_history[appid] = { "access_token": access_token, "expires_in": expires_in, - "access_token_time": str(access_token_time), + "access_token_time": access_token_time, "corpid": corpid, "appsecret": appsecret } @@ -258,7 +260,7 @@ class MessageForward(_PluginBase): appsecret = wechat_token['appsecret'] # 判断token有效期 - if (datetime.now() - access_token_time).seconds < expires_in: + if (datetime.now() - datetime.strptime(access_token_time, "%Y-%m-%d %H:%M:%S")).seconds < expires_in: # 重新获取token access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid, appsecret=appsecret) From eaf0d17118045263275d1739a0e9650700a38139 Mon Sep 17 00:00:00 2001 From: thsrite Date: Fri, 8 Sep 2023 13:13:11 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix=20=E6=B6=88=E6=81=AF=E8=BD=AC=E5=8F=91?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=B8=85=E7=90=86=E7=BC=93=E5=AD=98=E6=8C=89?= =?UTF-8?q?=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/plugins/messageforward/__init__.py | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/plugins/messageforward/__init__.py b/app/plugins/messageforward/__init__.py index 214a793d..cc29b69b 100644 --- a/app/plugins/messageforward/__init__.py +++ b/app/plugins/messageforward/__init__.py @@ -37,6 +37,7 @@ class MessageForward(_PluginBase): _enabled = False _wechat = None _pattern = None + _clean: bool = False _pattern_token = {} # 企业微信发送消息URL @@ -47,9 +48,19 @@ class MessageForward(_PluginBase): def init_plugin(self, config: dict = None): if config: self._enabled = config.get("enabled") + self._clean = config.get("clear") self._wechat = config.get("wechat") self._pattern = config.get("pattern") + if self._clean: + # 清理已有缓存 + self.del_data("wechat_token") + self.update_config({ + "enabled": self._enabled, + "clean": False, + "wechat": self._wechat, + "pattern": self._pattern + }) # 获取token存库 if self._enabled and self._wechat: self.__save_wechat_token() @@ -90,6 +101,22 @@ class MessageForward(_PluginBase): } } ] + }, + { + 'component': 'VCol', + 'props': { + 'cols': 12, + 'md': 6 + }, + 'content': [ + { + 'component': 'VSwitch', + 'props': { + 'model': 'clear', + 'label': '清除缓存' + } + } + ] } ] }, @@ -141,6 +168,7 @@ class MessageForward(_PluginBase): } ], { "enabled": False, + "clear": False, "wechat": "", "pattern": "" }