2022-07-26 15:54:48 +00:00
|
|
|
|
from telegram import Update
|
|
|
|
|
from telegram.ext import CommandHandler, CallbackContext
|
|
|
|
|
|
2022-08-05 11:14:29 +00:00
|
|
|
|
from apps.wiki.services import WikiService
|
2022-07-26 15:54:48 +00:00
|
|
|
|
from plugins.base import BasePlugins
|
|
|
|
|
from utils.decorators.admins import bot_admins_rights_check
|
|
|
|
|
from utils.decorators.error import error_callable
|
|
|
|
|
from utils.plugins.manager import listener_plugins_class
|
2022-08-06 09:27:34 +00:00
|
|
|
|
from utils.service.inject import inject
|
2022-07-26 15:54:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@listener_plugins_class()
|
|
|
|
|
class Wiki(BasePlugins):
|
2022-07-31 04:51:22 +00:00
|
|
|
|
"""有关WIKI操作"""
|
|
|
|
|
|
|
|
|
|
@inject
|
|
|
|
|
def __init__(self, wiki_service: WikiService):
|
|
|
|
|
self.wiki_service = wiki_service
|
2022-07-26 15:54:48 +00:00
|
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
|
def create_handlers(cls) -> list:
|
|
|
|
|
wiki = cls()
|
|
|
|
|
return [
|
|
|
|
|
CommandHandler("refresh_wiki", wiki.refresh_wiki, block=False),
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
@bot_admins_rights_check
|
|
|
|
|
@error_callable
|
2022-07-31 04:51:22 +00:00
|
|
|
|
async def refresh_wiki(self, update: Update, _: CallbackContext):
|
2022-07-26 15:54:48 +00:00
|
|
|
|
message = update.message
|
|
|
|
|
await message.reply_text("正在刷新Wiki缓存,请稍等")
|
2022-07-31 04:51:22 +00:00
|
|
|
|
await self.wiki_service.refresh_wiki()
|
2022-07-26 15:54:48 +00:00
|
|
|
|
await message.reply_text("刷新Wiki缓存成功")
|