MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / wecom_app

Function wecom_app

daily/notify.py:478–509  ·  view source on GitHub ↗

通过 企业微信 APP 推送消息。

(title: str, content: str)

Source from the content-addressed store, hash-verified

476
477
478def wecom_app(title: str, content: str) -> None:
479 """
480 通过 企业微信 APP 推送消息。
481 """
482 if not push_config.get("QYWX_AM"):
483 return
484 QYWX_AM_AY = re.split(",", push_config.get("QYWX_AM"))
485 if 4 < len(QYWX_AM_AY) > 5:
486 print("QYWX_AM 设置错误!!")
487 return
488 print("企业微信 APP 服务启动")
489
490 corpid = QYWX_AM_AY[0]
491 corpsecret = QYWX_AM_AY[1]
492 touser = QYWX_AM_AY[2]
493 agentid = QYWX_AM_AY[3]
494 try:
495 media_id = QYWX_AM_AY[4]
496 except IndexError:
497 media_id = ""
498 wx = WeCom(corpid, corpsecret, agentid)
499 # 如果没有配置 media_id 默认就以 text 方式发送
500 if not media_id:
501 message = title + "\n\n" + content
502 response = wx.send_text(message, touser)
503 else:
504 response = wx.send_mpnews(title, content, media_id, touser)
505
506 if response == "ok":
507 print("企业微信推送成功!")
508 else:
509 print("企业微信推送失败!错误信息如下:\n", response)
510
511
512class WeCom:

Callers

nothing calls this directly

Calls 5

send_textMethod · 0.95
send_mpnewsMethod · 0.95
printFunction · 0.70
WeComClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected