| """AstrBot 备份模块共享常量 |
| |
| 此文件定义了导出器和导入器共享的常量,确保两端配置一致。 |
| """ |
|
|
| from sqlmodel import SQLModel |
|
|
| from astrbot.core.db.po import ( |
| Attachment, |
| CommandConfig, |
| CommandConflict, |
| ConversationV2, |
| Persona, |
| PersonaFolder, |
| PlatformMessageHistory, |
| PlatformSession, |
| PlatformStat, |
| Preference, |
| ) |
| from astrbot.core.knowledge_base.models import ( |
| KBDocument, |
| KBMedia, |
| KnowledgeBase, |
| ) |
| from astrbot.core.utils.astrbot_path import ( |
| get_astrbot_config_path, |
| get_astrbot_plugin_data_path, |
| get_astrbot_plugin_path, |
| get_astrbot_t2i_templates_path, |
| get_astrbot_temp_path, |
| get_astrbot_webchat_path, |
| ) |
|
|
| |
| |
| |
|
|
| |
| MAIN_DB_MODELS: dict[str, type[SQLModel]] = { |
| "platform_stats": PlatformStat, |
| "conversations": ConversationV2, |
| "personas": Persona, |
| "persona_folders": PersonaFolder, |
| "preferences": Preference, |
| "platform_message_history": PlatformMessageHistory, |
| "platform_sessions": PlatformSession, |
| "attachments": Attachment, |
| "command_configs": CommandConfig, |
| "command_conflicts": CommandConflict, |
| } |
|
|
| |
| KB_METADATA_MODELS: dict[str, type[SQLModel]] = { |
| "knowledge_bases": KnowledgeBase, |
| "kb_documents": KBDocument, |
| "kb_media": KBMedia, |
| } |
|
|
|
|
| def get_backup_directories() -> dict[str, str]: |
| """获取需要备份的目录列表 |
| |
| 使用 astrbot_path 模块动态获取路径,支持通过环境变量 ASTRBOT_ROOT 自定义根目录。 |
| |
| Returns: |
| dict: 键为备份文件中的目录名称,值为目录的绝对路径 |
| """ |
| return { |
| "plugins": get_astrbot_plugin_path(), |
| "plugin_data": get_astrbot_plugin_data_path(), |
| "config": get_astrbot_config_path(), |
| "t2i_templates": get_astrbot_t2i_templates_path(), |
| "webchat": get_astrbot_webchat_path(), |
| "temp": get_astrbot_temp_path(), |
| } |
|
|
|
|
| |
| BACKUP_MANIFEST_VERSION = "1.1" |
|
|