mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-21 22:58:05 +00:00
693cd774d3
* 重构插件传入 `service` 方式 重构插件传入 `service` 方式 将 `create_handlers`函数的修饰符改为 `classmethod`
30 lines
827 B
Python
30 lines
827 B
Python
from telegram import Update
|
||
from telegram.ext import CommandHandler
|
||
|
||
from manager import listener_plugins_class
|
||
from plugins.admin import bot_admins_only
|
||
from plugins.base import BasePlugins
|
||
from utils.base import PaimonContext
|
||
|
||
|
||
@listener_plugins_class()
|
||
class Wiki(BasePlugins):
|
||
"""
|
||
有关WIKI
|
||
"""
|
||
|
||
@classmethod
|
||
def create_handlers(cls) -> list:
|
||
wiki = cls()
|
||
return [
|
||
CommandHandler("refresh_wiki", wiki.refresh_wiki, block=False),
|
||
]
|
||
|
||
@bot_admins_only
|
||
async def refresh_wiki(self, update: Update, context: PaimonContext):
|
||
message = update.message
|
||
service = context.service
|
||
await message.reply_text("正在刷新Wiki缓存,请稍等")
|
||
await service.wiki.refresh_wiki()
|
||
await message.reply_text("刷新Wiki缓存成功")
|