1 parent
d8ade5ba43
commit
0a578f4410
1 file changed
+37
-4
+37
-4
@@ -3,6 +3,25 @@ import http
|
||||
import json
|
||||
from typing import Dict, List, Optional
|
||||
|
||||
import hashlib
|
||||
import base64
|
||||
import hmac
|
||||
import time
|
||||
|
||||
|
||||
def gen_sign(timestamp, secret):
|
||||
# 拼接timestamp和secret
|
||||
string_to_sign = "{}\n{}".format(timestamp, secret)
|
||||
hmac_code = hmac.new(
|
||||
string_to_sign.encode("utf-8"), digestmod=hashlib.sha256
|
||||
).digest()
|
||||
|
||||
# 对结果进行base64处理
|
||||
sign = base64.b64encode(hmac_code).decode("utf-8")
|
||||
|
||||
return sign
|
||||
|
||||
|
||||
# 配置参数
|
||||
CONFIG = {
|
||||
"BASE_URL": "https://boss-api.shadow-rpa.net/boss/api/v1",
|
||||
@@ -174,7 +193,7 @@ def decrypt_sensitive_data(
|
||||
def feishu_notify(text):
|
||||
|
||||
webhook_url = "/open-apis/bot/v2/hook/d6551d8c-d792-46e4-929d-ad0d1b031027"
|
||||
Keys = "lPQwjE2TqMD0Q4q0zDlUY"
|
||||
keys = "lPQwjE2TqMD0Q4q0zDlUY"
|
||||
|
||||
conn = http.client.HTTPSConnection("open.feishu.cn")
|
||||
payload = json.dumps({"msg_type": "text", "content": {"text": text}})
|
||||
@@ -189,12 +208,24 @@ def feishu_notify_to_xbot_content_group(text):
|
||||
webhook_url = "/open-apis/bot/v2/hook/b2db78ac-799a-4251-8341-18d49091fa62"
|
||||
Keys = "T8phm8fcfZ04bvOHaI0kzd"
|
||||
|
||||
timestamp = str(int(time.time()))[:10]
|
||||
# print(timestamp)
|
||||
sign = gen_sign(timestamp, Keys)
|
||||
|
||||
conn = http.client.HTTPSConnection("open.feishu.cn")
|
||||
payload = json.dumps({"msg_type": "text", "content": {"text": text}})
|
||||
payload = json.dumps(
|
||||
{
|
||||
"msg_type": "text",
|
||||
"content": {"text": text},
|
||||
"sign": sign,
|
||||
"timestamp": timestamp,
|
||||
}
|
||||
)
|
||||
headers = {"Content-Type": "application/json"}
|
||||
conn.request("POST", webhook_url, payload, headers)
|
||||
res = conn.getresponse()
|
||||
data = res.read()
|
||||
print(data)
|
||||
|
||||
|
||||
def main():
|
||||
@@ -252,13 +283,15 @@ def main():
|
||||
)
|
||||
# break
|
||||
messages = "\n".join(messages)
|
||||
|
||||
if messages.strip():
|
||||
print("发送飞书通知")
|
||||
feishu_notify(text=messages)
|
||||
|
||||
message_without_phone = "\n".join(message_without_phone)
|
||||
|
||||
if message_without_phone.strip():
|
||||
message_without_phone = "\n".join(message_without_phone)
|
||||
print("发送飞书通知")
|
||||
print("发送飞书通知到内容组")
|
||||
feishu_notify_to_xbot_content_group(text=message_without_phone)
|
||||
|
||||
except requests.RequestException as e:
|
||||
|
||||
Reference in new issue
Block a user