|
@@ -1,16 +1,14 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+"""
|
|
|
+Created on 2022-06-15
|
|
|
+---------
|
|
|
+@summary: 企业微信机器人
|
|
|
+---------
|
|
|
+@author: Dzr
|
|
|
+"""
|
|
|
import requests
|
|
|
|
|
|
-import platform
|
|
|
-
|
|
|
-# 企业微信联系人
|
|
|
-MOBILE_LIST = [
|
|
|
- "15639297172", # 张金坤
|
|
|
-]
|
|
|
-
|
|
|
-if platform.system() not in ['Darwin', 'Windows']:
|
|
|
- PLATFORM_RUL = "http://pycaptcha.spdata.jianyu360.com"
|
|
|
-else:
|
|
|
- PLATFORM_RUL = "http://127.0.0.1:2119"
|
|
|
+import setting
|
|
|
|
|
|
|
|
|
def post_data(platform, limit, usage, msg, allow_reset=False):
|
|
@@ -29,7 +27,7 @@ def post_data(platform, limit, usage, msg, allow_reset=False):
|
|
|
c1 = ">调用次数: <font color=\"comment\">{}次</font>".format(usage)
|
|
|
msg = "{}\n {}\n > {}\n > {}\n".format(label, platform, c0, c1)
|
|
|
if allow_reset:
|
|
|
- c2 = f"[解除限制]({PLATFORM_RUL}/v1/images/reset)"
|
|
|
+ c2 = f"[解除限制]({setting.PLATFORM_API}/v1/images/reset)"
|
|
|
msg = "{}[{}]\n > {}\n > {}\n {}".format(label, c2, platform, c0, c1)
|
|
|
|
|
|
content = msg
|
|
@@ -38,7 +36,7 @@ def post_data(platform, limit, usage, msg, allow_reset=False):
|
|
|
"msgtype": "text",
|
|
|
"text": {
|
|
|
"content": " 请以下同事注意",
|
|
|
- "mentioned_mobile_list": MOBILE_LIST
|
|
|
+ "mentioned_mobile_list": setting.WECHAT_WARNING_PHONES
|
|
|
}
|
|
|
}
|
|
|
body = {'markdown': markdown, 'text': text}
|
|
@@ -46,9 +44,9 @@ def post_data(platform, limit, usage, msg, allow_reset=False):
|
|
|
|
|
|
|
|
|
def robot_webhook(data):
|
|
|
- url = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send"
|
|
|
headers = {"Content-Type": "application/json"}
|
|
|
- params = {"key": "683a19fe-c72d-464f-acbe-489656f06b05"}
|
|
|
+ params = {"key": setting.WECHAT_WARNING_ROBOT_KEY}
|
|
|
+ url = setting.WECHAT_WARNING_URL
|
|
|
response = requests.post(url, headers=headers, params=params, json=data)
|
|
|
return response.json()
|
|
|
|