diff options
author | Ruoqi Yang <[email protected]> | 2022-09-25 15:35:49 +0800 |
---|---|---|
committer | Ruoqi Yang <[email protected]> | 2022-09-25 22:53:39 +0800 |
commit | d4ba45afd544e7d0f532eff5011bd289e10e26bf (patch) | |
tree | 940c01d7422047c5eed330f9e2dc92988d6f9161 /ATRI/plugins/__init__.py | |
parent | c234d65b536a21e40d9edde00bbbd546273a5464 (diff) | |
download | ATRI-d4ba45afd544e7d0f532eff5011bd289e10e26bf.tar.gz ATRI-d4ba45afd544e7d0f532eff5011bd289e10e26bf.tar.bz2 ATRI-d4ba45afd544e7d0f532eff5011bd289e10e26bf.zip |
fix: handle text msg recall
fix: BaseBotException is not catched by nonebot (and printed)
fix: database startup at module level to enable load a single plugin
Diffstat (limited to 'ATRI/plugins/__init__.py')
-rw-r--r-- | ATRI/plugins/__init__.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ATRI/plugins/__init__.py b/ATRI/plugins/__init__.py new file mode 100644 index 0000000..6ca629c --- /dev/null +++ b/ATRI/plugins/__init__.py @@ -0,0 +1,43 @@ +from ATRI.database import init_database, close_database_connection +from ATRI.utils.check_update import CheckUpdate +from ATRI.log import logger as log +from ATRI.utils.apscheduler import scheduler +import ATRI + +from time import sleep + +driver = ATRI.driver() + + [email protected]_startup +async def startup(): + await init_database() + + log.info(f"Now running: {ATRI.__version__}") + + log.info("Starting to check update...") + commit_info = await CheckUpdate.show_latest_commit_info() + if commit_info: + log.info(commit_info) + + l_v, l_v_t = await CheckUpdate.show_latest_version() + if l_v and l_v_t: + if l_v != ATRI.__version__: + log.warning("新版本已发布, 请更新.") + log.warning(f"最新版本: {l_v} 更新时间: {l_v_t}") + sleep(3) + + if not scheduler.running: + scheduler.start() + log.info("Scheduler Started.") + + log.info("アトリは、高性能ですから!") + + [email protected]_shutdown +async def shutdown(): + await close_database_connection() + + scheduler.shutdown(False) + + log.info("Thanks for using.") |