# 配置信息
config = {
'wecom': {
'corpid': config_parser.get('WeChat', 'CorpID'),
'corpsecret': config_parser.get('WeChat', 'CorpSecret')
},
'domain': config_parser.get('Domain', 'Name'),
'exclude_departments': [d.strip() for d in config_parser.get('ExcludeDepartments', 'Names').split(',')],
'exclude_accounts': [
*[acc.strip() for acc in config_parser.get('ExcludeUsers', 'SystemAccounts').split(',') if acc.strip()],
*[acc.strip() for acc in config_parser.get('ExcludeUsers', 'CustomAccounts').split(',') if acc.strip()]
],
'webhook_url': config_parser.get('WeChatBot', 'WebhookUrl')
}
# 验证机器人webhook地址
if not config['webhook_url'] or 'key=' not in config['webhook_url']:
logger.error("企业微信机器人webhook地址无效")
raise ValueError("无效的webhook地址")
bot = WeChatBot(config['webhook_url'])