From d7d18ada1e263285cb498afc6ab5e2cae509c8ee Mon Sep 17 00:00:00 2001 From: yzhh <31803608+OasisAkari@users.noreply.github.com> Date: Wed, 30 Aug 2023 21:17:25 +0800 Subject: [PATCH] #655 --- DEPLOY.md | 7 +++++-- core/utils/bot.py | 6 ++++++ modules/core/locales/zh_cn.json | 2 +- modules/core/utils.py | 4 +--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/DEPLOY.md b/DEPLOY.md index b603f488..e056b14b 100644 --- a/DEPLOY.md +++ b/DEPLOY.md @@ -48,9 +48,12 @@ **方式二:直接下载代码** -1. 从 [Release 页面](https://github.com/Teahouse-Studios/bot/releases/latest) 的 Assets 板块中下载 Source code(源代码)。当然,您也可以下载 [master 分支的最新代码](https://github.com/Teahouse-Studios/akari-bot/archive/refs/heads/master.zip)。 +1. 您可以下载 [master 分支的最新代码](https://github.com/Teahouse-Studios/akari-bot/archive/refs/heads/master.zip)。 - > 注意:master 分支下的部署文档可能会有所不同,请在下载对应版本的源码后打开目录下的 DEPLOY.md 继续查看部署教程。 + > 由于无法保证 release 版本的稳定性,我们不再提供 release 版本的下载。 + + > 不建议直接下载代码部署,因为这样您将无法使用 git 或是使用机器人内置的命令更新代码。 + 2. 解压源代码,按住 `Shift` + `右键`,选择 `在此处打开 Powershell 窗口` 或 `在此处打开命令窗口` 来打开终端,进入文件夹。 **Linux** diff --git a/core/utils/bot.py b/core/utils/bot.py index 76f3a0b2..ab6bced9 100644 --- a/core/utils/bot.py +++ b/core/utils/bot.py @@ -27,6 +27,12 @@ async def init_async(start_scheduler=True) -> None: Scheduler.start() logging.getLogger('apscheduler.executors.default').setLevel(logging.WARNING) await load_secret() + version = os.path.abspath(PrivateAssets.path + '/version') + with open(version, 'w') as write_version: + try: + write_version.write(os.popen('git rev-parse HEAD', 'r').read()[0:6]) + except Exception as e: + write_version.write('unknown') Logger.info(f'Hello, {bot_name}!') diff --git a/modules/core/locales/zh_cn.json b/modules/core/locales/zh_cn.json index 577c5189..0144e3cc 100644 --- a/modules/core/locales/zh_cn.json +++ b/modules/core/locales/zh_cn.json @@ -152,7 +152,7 @@ "core.message.toggle.check.enable": "已开启错字检查提示。", "core.message.toggle.typing.disable": "已关闭输入提示。", "core.message.toggle.typing.enable": "已开启输入提示。", - "core.message.version": "当前机器人版本号:${version_tag}(${commit})", + "core.message.version": "当前机器人版本号:${commit}", "core.message.whoami": "你的 ID 是:${senderid}\n本对话的 ID 是:${targetid}", "core.message.whoami.admin": "(你拥有本对话的管理员权限)", "core.message.whoami.botadmin": "(你拥有本对话的机器人管理员权限)", diff --git a/modules/core/utils.py b/modules/core/utils.py index a8187309..a807a835 100644 --- a/modules/core/utils.py +++ b/modules/core/utils.py @@ -21,10 +21,8 @@ version = module('version', base=True, desc='{core.help.version}', developers=[' async def bot_version(msg: Bot.MessageSession): ver = os.path.abspath(PrivateAssets.path + '/version') - tag = os.path.abspath(PrivateAssets.path + '/version_tag') open_version = open(ver, 'r') - open_tag = open(tag, 'r') - msgs = msg.locale.t('core.message.version', version_tag=open_tag.read(), commit=open_version.read()) + msgs = msg.locale.t('core.message.version', commit=open_version.read()) open_version.close() await msg.finish(msgs, msgs)