一些Log格式错误被删除
This commit is contained in:
@@ -30,7 +30,7 @@ class PluginInterface(ABC):
|
||||
chat_id: 会话ID
|
||||
user_id: 用户ID
|
||||
'''
|
||||
config.Log("Warning", f"插件{self.__class__.__name__}未实现callback方法")
|
||||
config.Log("Warning", f"{ConsoleFrontColor.YELLOW}插件{self.__class__.__name__}未实现callback方法{ConsoleFrontColor.RESET}")
|
||||
return ""
|
||||
|
||||
def execute(self, path:str) -> Optional[APIRouter]:
|
||||
@@ -45,9 +45,13 @@ class PluginInterface(ABC):
|
||||
db = get_db()
|
||||
db_model = self.register_db_model()
|
||||
if db_model:
|
||||
db.define_table(db_model.table_name)
|
||||
for name, field_def in db_model.column_defs.items():
|
||||
db.define_column(db_model.table_name, name, field_def)
|
||||
cursor = db.conn.cursor()
|
||||
sql = f"CREATE TABLE IF NOT EXISTS {db_model.table_name} ({', '.join([f'{name} {field_def}' for name, field_def in db_model.column_defs.items()])})"
|
||||
config.Log("Info", f"{ConsoleFrontColor.LIGHTMAGENTA_EX}为表 {db_model.table_name} 创建: {sql}{ConsoleFrontColor.RESET}")
|
||||
try:
|
||||
cursor.execute(sql)
|
||||
except Exception as e:
|
||||
config.Log("Error", f"{ConsoleFrontColor.RED}为表 {db_model.table_name} 创建失败: {e}{ConsoleFrontColor.RESET}")
|
||||
|
||||
return router
|
||||
|
||||
@@ -77,16 +81,16 @@ class PluginInterface(ABC):
|
||||
将插件注册, 使其可以被命令匹配
|
||||
'''
|
||||
if command in PluginInterface.plugin_instances:
|
||||
config.Log("Warning", f"插件{PluginInterface.plugin_instances[command].__class__.__name__}已注册命令{command}, 将被新插件{self.__class__.__name__}覆盖")
|
||||
config.Log("Warning", f"{ConsoleFrontColor.YELLOW}插件{PluginInterface.plugin_instances[command].__class__.__name__}已注册命令{command}, 将被新插件{self.__class__.__name__}覆盖{ConsoleFrontColor.RESET}")
|
||||
else:
|
||||
config.Log("Info", f"插件{self.__class__.__name__}已注册命令{command}")
|
||||
PluginInterface.plugin_instances[command] = self
|
||||
|
||||
def register_db_model(self) -> DatabaseModel:
|
||||
def register_db_model(self) -> Optional[DatabaseModel]:
|
||||
'''
|
||||
继承后重写该方法注册数据库模型
|
||||
'''
|
||||
return DatabaseModel()
|
||||
return None
|
||||
|
||||
def is_enable_plugin(self) -> bool:
|
||||
'''
|
||||
|
||||
Reference in New Issue
Block a user