Refactor the cron job functionality to transition from a crawling to a searching model. Update related documentation and scripts to reflect the new terminology and functionality, including changes in the README and script comments. Enhance WeChat menu and message handling to support the new search features, ensuring clarity in user interactions and logging.

This commit is contained in:
2026-01-09 08:19:09 +08:00
parent 4000438f49
commit 72dc40186d
20 changed files with 5935 additions and 595 deletions
+73
View File
@@ -0,0 +1,73 @@
#!/usr/bin/env python3
"""
创建企业微信菜单脚本
"""
import sys
import os
# 添加项目路径
sys.path.insert(0, os.path.dirname(__file__))
try:
from gx_gp_monitor.wechat.menu_manager import WeChatMenuManager
from gx_gp_monitor.core.config_manager import load_config
def main():
"""主函数"""
print("🚀 开始创建企业微信菜单...")
print("=" * 50)
try:
# 加载配置
load_config()
print("✅ 配置加载成功")
# 创建菜单管理器
menu_manager = WeChatMenuManager()
print("✅ 菜单管理器初始化成功")
# 显示当前菜单结构
menu_info = menu_manager.get_menu_info()
print("\n📋 菜单结构预览:")
for button in menu_info['menu_structure']['buttons']:
sub_count = len(button.get('sub_buttons', [])) if isinstance(button.get('sub_buttons'), list) else button.get('sub_buttons', 0)
print(f"{button['name']} ({sub_count}个子菜单)")
if isinstance(button.get('sub_buttons'), list):
for sub_btn in button['sub_buttons']:
print(f" - {sub_btn['name']}")
print("\n🔄 正在创建菜单到企业微信...")
# 创建菜单
result = menu_manager.create_menu()
if result:
print("✅ 企业微信菜单创建成功!")
print("\n💡 菜单功能说明:")
print("• 🚀 监控操作:搜索、统计、筛选等核心功能")
print("• ⚙️ 系统管理:状态监控、维护操作")
print("• ❓ 帮助:使用说明和联系方式")
print("\n🎯 现在可以在企业微信中查看和使用新菜单了!")
else:
print("❌ 企业微信菜单创建失败")
print("💡 可能的原因:")
print("• 企业微信配置错误")
print("• 网络连接问题")
print("• API权限不足")
print("• 请检查日志文件获取详细错误信息")
except Exception as e:
print(f"❌ 创建菜单失败: {str(e)}")
print("请检查配置和网络连接")
if __name__ == "__main__":
main()
except ImportError as e:
print(f"❌ 导入失败: {e}", file=sys.stderr)
print("请确保已安装所有依赖: pip install -r gx_gp_monitor/requirements.txt", file=sys.stderr)
sys.exit(1)
except Exception as e:
print(f"❌ 脚本执行失败: {e}", file=sys.stderr)
sys.exit(1)