diff --git a/README.md b/README.md
index 5d97712..b3cf616 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,7 @@ docker run -d -v [配置文件的绝对路径]/config.yml:/mnt/config.yml nfew/a
|---------------|------------------|:-------:|-------------------------------------------------------------------------------------------------------------|
| Server酱_Turbo | serverChan_turbo | ❌ | 🤖方便,不用安装app,免费用户5次/天,适合频率不高的用户
👉https://sct.ftqq.com |
| 企业微信自建应用 | wecom_apps | ✅ | 😢新用户不再推荐,2022年6月20日之后新创建的应用,需要配置可信IP
👉https://work.weixin.qq.com/wework_admin/frame#apps/createApiApp |
+| 企业微信群聊机器人 | wecom_bot | ✅ | 🥳推荐,新建群聊添加自定义机器人即可
👉https://developer.work.weixin.qq.com/document/path/99110 |
| 钉钉群聊机器人 | dingtalk_bot | ✅ | 🥳推荐,新建群聊添加自定义机器人即可,自定义关键词使用"【"
👉https://open.dingtalk.com/document/robots/custom-robot-access |
| 飞书自建应用 | feishu_apps | ✅ | 🤔可以使用个人版,创建应用,授予其机器人权限
👉https://open.feishu.cn/app?lang=zh-CN |
| 飞书群聊机器人 | feishu_bot | ❌(暂不支持) | 🤩推荐,新建群聊添加自定义机器人即可,自定义关键词使用"【"
👉https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot |
diff --git a/common/util.py b/common/util.py
index a8915b6..18de633 100644
--- a/common/util.py
+++ b/common/util.py
@@ -1,9 +1,13 @@
import requests
+import urllib3
from fake_useragent import UserAgent
from common.logger import log
from common.proxy import my_proxy
+# 关闭ssl警告
+urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
+
ua = UserAgent(os=["macos"], min_version=120.0)
@@ -19,7 +23,7 @@ def requests_get(url, module_name="未指定", headers=None, params=None, use_pr
headers.setdefault('user-agent', random_ua)
proxies = _get_proxy() if use_proxy else None
try:
- response = requests.get(url, headers=headers, params=params, proxies=proxies, timeout=10)
+ response = requests.get(url, headers=headers, params=params, proxies=proxies, timeout=10, verify=False)
except Exception as e:
log.error(f"【{module_name}】:{e}", exc_info=True)
return None
@@ -34,7 +38,7 @@ def requests_post(url, module_name="未指定", headers=None, params=None, data=
headers.setdefault('user-agent', random_ua)
proxies = _get_proxy() if use_proxy else None
try:
- response = requests.post(url, headers=headers, params=params, data=data, json=json, proxies=proxies, timeout=10)
+ response = requests.post(url, headers=headers, params=params, data=data, json=json, proxies=proxies, timeout=10, verify=False)
except Exception as e:
log.error(f"【{module_name}】:{e}", exc_info=True)
return None
diff --git a/config.yml b/config.yml
index 8f1044c..57b743d 100644
--- a/config.yml
+++ b/config.yml
@@ -112,6 +112,11 @@ push_channel:
agent_id:
# 应用Secret,如果启动该推送则必填
corp_secret:
+ - name: 推送通道_企业微信机器人
+ enable: false
+ type: wecom_bot
+ # 机器人key,如果启动该推送则必填
+ key:
- name: 推送通道_钉钉机器人
enable: false
type: dingtalk_bot
diff --git a/docs/image/aio-dynamic-push.png b/docs/image/aio-dynamic-push.png
index e2e6b18..d7b8569 100644
Binary files a/docs/image/aio-dynamic-push.png and b/docs/image/aio-dynamic-push.png differ
diff --git a/push_channel/__init__.py b/push_channel/__init__.py
index e9896e9..bd57735 100644
--- a/push_channel/__init__.py
+++ b/push_channel/__init__.py
@@ -10,6 +10,7 @@
from .telegram_bot import TelegramBot
from .webhook import Webhook
from .wecom_apps import WeComApps
+from .wecom_bot import WeComBot
push_channel_dict = {}
@@ -20,6 +21,8 @@ def get_push_channel(config):
return ServerChanTurbo(config)
if channel_type == "wecom_apps":
return WeComApps(config)
+ if channel_type == "wecom_bot":
+ return WeComBot(config)
if channel_type == "dingtalk_bot":
return DingtalkBot(config)
if channel_type == "feishu_apps":
diff --git a/push_channel/wecom_bot.py b/push_channel/wecom_bot.py
new file mode 100644
index 0000000..f24a2ea
--- /dev/null
+++ b/push_channel/wecom_bot.py
@@ -0,0 +1,41 @@
+import json
+
+from common import util
+from common.logger import log
+from . import PushChannel
+
+
+class WeComBot(PushChannel):
+ def __init__(self, config):
+ super().__init__(config)
+ self.key = str(config.get("key", ""))
+ if self.key == "":
+ log.error(f"【推送_{self.name}】配置不完整,推送功能将无法正常使用")
+
+ def push(self, title, content, jump_url=None, pic_url=None):
+ push_url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send"
+ headers = {
+ "Content-Type": "application/json"
+ }
+ params = {
+ "key": self.key
+ }
+ body = {
+ "msgtype": "news",
+ "news": {
+ "articles": [
+ {
+ "title": title,
+ "description": content,
+ "url": jump_url,
+ }
+ ]
+ }
+ }
+
+ if pic_url is not None:
+ body["news"]["articles"][0]["picurl"] = pic_url
+
+ response = util.requests_post(push_url, self.name, headers=headers, params=params, data=json.dumps(body))
+ push_result = "成功" if util.check_response_is_ok(response) else "失败"
+ log.info(f"【推送_{self.name}】{push_result}")
diff --git a/requirements.txt b/requirements.txt
index 247d6b0..5822560 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -4,3 +4,4 @@ PyYAML==6.0.1
requests==2.31.0
requests_toolbelt==1.0.0
schedule==1.2.1
+urllib3==1.26.9