From fb4457769957801886b55fcf9b8be8ac4889be3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Tue, 26 Jul 2022 23:54:48 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0=20wiki=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/wiki.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 plugins/wiki.py diff --git a/plugins/wiki.py b/plugins/wiki.py new file mode 100644 index 0000000..79be5e1 --- /dev/null +++ b/plugins/wiki.py @@ -0,0 +1,32 @@ +from telegram import Update +from telegram.ext import CommandHandler, CallbackContext + +from app.wiki.service import WikiService +from plugins.base import BasePlugins +from utils.app.inject import inject +from utils.decorators.admins import bot_admins_rights_check +from utils.decorators.error import error_callable +from utils.plugins.manager import listener_plugins_class + + +@listener_plugins_class() +class Wiki(BasePlugins): + """ + 有关WIKI + """ + + @classmethod + def create_handlers(cls) -> list: + wiki = cls() + return [ + CommandHandler("refresh_wiki", wiki.refresh_wiki, block=False), + ] + + @inject + @bot_admins_rights_check + @error_callable + async def refresh_wiki(self, update: Update, _: CallbackContext, wiki_service: WikiService = None): + message = update.message + await message.reply_text("正在刷新Wiki缓存,请稍等") + await wiki_service.refresh_wiki() + await message.reply_text("刷新Wiki缓存成功")