From 69ee1567de0fd5616e77db2efb9cc9d989dd2c45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Sun, 18 Sep 2022 16:11:09 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=E6=97=A5?= =?UTF-8?q?=E8=AE=B0=E5=8F=91=E9=80=81=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/system/log.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 plugins/system/log.py diff --git a/plugins/system/log.py b/plugins/system/log.py new file mode 100644 index 0000000..d386720 --- /dev/null +++ b/plugins/system/log.py @@ -0,0 +1,27 @@ +import os + +from telegram import Update +from telegram.ext import CommandHandler, CallbackContext + +from core.plugin import Plugin, handler +from utils.decorators.admins import bot_admins_rights_check + +current_dir = os.getcwd() +error_log = os.path.join(current_dir, "logs", "error", "error.log") +debug_log = os.path.join(current_dir, "logs", "debug", "debug.log") + + +class Log(Plugin): + + @handler(CommandHandler, command="send_log", block=False) + @bot_admins_rights_check + async def send_log(self, update: Update, _: CallbackContext): + message = update.effective_message + if os.path.exists(error_log): + await message.reply_document(open(error_log, mode='rb+'), caption="Error Log") + else: + await message.reply_text("错误日记未找到") + if os.path.exists(debug_log): + await message.reply_document(open(debug_log, mode='rb+'), caption="Debug Log") + else: + await message.reply_text("调试日记未找到")