⭐AI-driven public opinion & trend monitor with multi-platform aggregation, RSS, and smart alerts.🎯 告别信息过载,你的 AI 舆情监控助手与热点筛选工具!聚合多平台热点 + RSS 订阅,支持关键词精准筛选。AI 智能筛选新闻 + AI 翻译 + AI 分析简报直推手机,也支持接入 MCP 架构,赋能 AI 自然语言对话分析、情感洞察与趋势预测等。支持 Docker ,数据本地/云端自持。集成微信/飞书/钉钉/Telegram/邮件/ntfy/bark/slack 等渠道智能推送。
Python aibarkdata-analysisdockerhot-newsllmmailmcpmcp-servernewsntfypythonrsstrending-topicswechatwework
"""
配置管理工具
实现配置查询和管理功能。
"""
from typing import Dict, Optional, Any, TypedDict
from ..services.data_service import DataService
from ..utils.validators import validate_config_section
from ..utils.errors import MCPError
class ErrorInfo(TypedDict, total=False):
"""错误信息结构"""
code: str
message: str
suggestion: str
class ConfigResult(TypedDict):
"""配置查询结果 - success 字段必需,其他字段可选"""
success: bool
config: Optional[Dict[str, Any]]
section: Optional[str]
error: Optional[ErrorInfo]
class ConfigManagementTools:
"""配置管理工具类"""
def __init__(self, project_root: str = None):
"""
初始化配置管理工具
Args:
project_root: 项目根目录
"""
self.data_service = DataService(project_root)
def get_current_config(self, section: Optional[str] = None) -> ConfigResult:
"""
获取当前系统配置
Args:
section: 配置节 - all/crawler/push/keywords/weights,默认all
Returns:
配置字典
Example:
>>> tools = ConfigManagementTools()
>>> result = tools.get_current_config(section="crawler")
>>> print(result['crawler']['platforms'])
"""
try:
# 参数验证
section = validate_config_section(section)
# 获取配置
config = self.data_service.get_current_config(section=section)
return ConfigResult(
success=True,
config=config,
section=section,
error=None
)
except MCPError as e:
return ConfigResult(
success=False,
config=None,
section=None,
error=e.to_dict()
)
except Exception as e:
return ConfigResult(
success=False,
config=None,
section=None,
error={"code": "INTERNAL_ERROR", "message": str(e), "suggestion": "请查看服务日志获取详细信息"}
)