修改变量 PluginsClass 的声明类型为 List[BasePlugins]

This commit is contained in:
洛水居室 2022-06-27 23:41:27 +08:00
parent ff26e814d2
commit e04aa8476c
No known key found for this signature in database
GPG Key ID: C9DE87DA724B88FC

View File

@ -2,17 +2,18 @@ import os
from glob import glob from glob import glob
from importlib import import_module from importlib import import_module
from os import path from os import path
from typing import Callable, List, Union from typing import List, Union
from telegram.ext import Application from telegram.ext import Application
from logger import Log from logger import Log
from plugins.base import BasePlugins
PluginsClass: List[Callable] = [] PluginsClass: List[BasePlugins] = []
def listener_plugins_class(): def listener_plugins_class():
def decorator(func: Callable): def decorator(func: BasePlugins):
PluginsClass.append( PluginsClass.append(
func func
) )
@ -64,7 +65,7 @@ class PluginsManager:
for pc in PluginsClass: for pc in PluginsClass:
if callable(pc): if callable(pc):
try: try:
ist = pc(*args) ist: BasePlugins = pc(*args)
handlers_list = ist.create_handlers(*args) handlers_list = ist.create_handlers(*args)
for handler in handlers_list: for handler in handlers_list:
application.add_handler(handler) application.add_handler(handler)