Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
eb1e045d8f
@ -37,6 +37,7 @@ class MessageForward(_PluginBase):
|
|||||||
_enabled = False
|
_enabled = False
|
||||||
_wechat = None
|
_wechat = None
|
||||||
_pattern = None
|
_pattern = None
|
||||||
|
_clean: bool = False
|
||||||
_pattern_token = {}
|
_pattern_token = {}
|
||||||
|
|
||||||
# 企业微信发送消息URL
|
# 企业微信发送消息URL
|
||||||
@ -47,9 +48,19 @@ class MessageForward(_PluginBase):
|
|||||||
def init_plugin(self, config: dict = None):
|
def init_plugin(self, config: dict = None):
|
||||||
if config:
|
if config:
|
||||||
self._enabled = config.get("enabled")
|
self._enabled = config.get("enabled")
|
||||||
|
self._clean = config.get("clear")
|
||||||
self._wechat = config.get("wechat")
|
self._wechat = config.get("wechat")
|
||||||
self._pattern = config.get("pattern")
|
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存库
|
# 获取token存库
|
||||||
if self._enabled and self._wechat:
|
if self._enabled and self._wechat:
|
||||||
self.__save_wechat_token()
|
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,
|
"enabled": False,
|
||||||
|
"clear": False,
|
||||||
"wechat": "",
|
"wechat": "",
|
||||||
"pattern": ""
|
"pattern": ""
|
||||||
}
|
}
|
||||||
@ -220,10 +248,12 @@ class MessageForward(_PluginBase):
|
|||||||
access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid,
|
access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid,
|
||||||
appsecret=appsecret)
|
appsecret=appsecret)
|
||||||
if access_token:
|
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] = {
|
wechat_token_history[appid] = {
|
||||||
"access_token": access_token,
|
"access_token": access_token,
|
||||||
"expires_in": expires_in,
|
"expires_in": expires_in,
|
||||||
"access_token_time": str(access_token_time),
|
"access_token_time": access_token_time,
|
||||||
"corpid": corpid,
|
"corpid": corpid,
|
||||||
"appsecret": appsecret
|
"appsecret": appsecret
|
||||||
}
|
}
|
||||||
@ -258,7 +288,7 @@ class MessageForward(_PluginBase):
|
|||||||
appsecret = wechat_token['appsecret']
|
appsecret = wechat_token['appsecret']
|
||||||
|
|
||||||
# 判断token有效期
|
# 判断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
|
# 重新获取token
|
||||||
access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid,
|
access_token, expires_in, access_token_time = self.__get_access_token(corpid=corpid,
|
||||||
appsecret=appsecret)
|
appsecret=appsecret)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user