first commit
continuous-integration/drone/push Build is failing

This commit is contained in:
jianxin committed 2025-02-18 10:40:39 +08:00
1 parent 0a578f4410
commit 1a46343419
1 file changed
+72 -18
+72 -18
View File
@@ -9,6 +9,22 @@ import hmac
import time
import lark_oapi as lark
from lark_oapi.api.bitable.v1 import *
# 配置参数
CONFIG = {
"BASE_URL": "https://boss-api.shadow-rpa.net/boss/api/v1",
"TOKEN": "234e69f9-939d-44e0-8b8f-1560ba77e375",
"newDutyUuid": "a16edf00-c99f-44ae-bbb9-56d3e3629386",
"BITTABLE_APP_ID": "cli_a5110cd1da70900b",
"BITTABLE_APP_SECRET": "XwTUlUq7dGK1XexUS7ljShJJ7t1MIwXF",
"BITTABLE_APP_TOKEN": "KppebaHOsaHGMxslbLRc82amn5f",
"BITTABLE_APP_TABLE_ID": "tblH8KwM2grwj9DI",
}
def gen_sign(timestamp, secret):
# 拼接timestamp和secret
string_to_sign = "{}\n{}".format(timestamp, secret)
@@ -22,14 +38,6 @@ def gen_sign(timestamp, secret):
return sign
# 配置参数
CONFIG = {
"BASE_URL": "https://boss-api.shadow-rpa.net/boss/api/v1",
"TOKEN": "234e69f9-939d-44e0-8b8f-1560ba77e375",
"newDutyUuid": "a16edf00-c99f-44ae-bbb9-56d3e3629386",
}
def get_headers(token: Optional[str] = None) -> Dict:
"""
生成请求头
@@ -203,6 +211,41 @@ def feishu_notify(text):
data = res.read()
def add_bittable_record(data):
# 创建client
client = (
lark.Client.builder()
.app_id(CONFIG["BITTABLE_APP_ID"])
.app_secret(CONFIG["BITTABLE_APP_SECRET"])
.log_level(lark.LogLevel.DEBUG)
.build()
)
# 构造请求对象
request: CreateAppTableRecordRequest = (
CreateAppTableRecordRequest.builder()
.app_token(CONFIG["BITTABLE_APP_TOKEN"])
.table_id(CONFIG["BITTABLE_APP_TABLE_ID"])
.request_body(AppTableRecord.builder().fields(data).build())
.build()
)
# 发起请求
response: CreateAppTableRecordResponse = client.bitable.v1.app_table_record.create(
request
)
# 处理失败返回
if not response.success():
lark.logger.error(
f"client.bitable.v1.app_table_record.create failed, code: {response.code}, msg: {response.msg}, log_id: {response.get_log_id()}, resp: \n{json.dumps(json.loads(response.raw.content), indent=4, ensure_ascii=False)}"
)
return
# 处理业务结果
lark.logger.info(lark.JSON.marshal(response.data, indent=4))
def feishu_notify_to_xbot_content_group(text):
webhook_url = "/open-apis/bot/v2/hook/b2db78ac-799a-4251-8341-18d49091fa62"
@@ -259,8 +302,7 @@ def main():
)
print(f"{'='*40}\n")
# 通知提交者
# 剑心通知
messages.append(
# f"工单ID: {processed_order['uuid']}\n"
f"提交者: {processed_order['submitter']}\n"
@@ -270,6 +312,7 @@ def main():
f"邀约: 我是影刀的小伙伴, 想跟你沟通反馈的需求: {processed_order['content']}\n\n"
)
# 群组通知
message_without_phone.append(
f"工单ID: {processed_order['uuid']}\n"
f"提交者: {processed_order['submitter']}\n"
@@ -277,22 +320,33 @@ def main():
f"企业: {processed_order['enterprise'] or '未找到'}\n"
)
# 表格同步
data = {
"企业": processed_order["enterprise"] or "社区版",
"手机号": processed_order["phone"],
"提交人": processed_order["submitter"],
"需求ID": processed_order["uuid"],
"需求内容": processed_order["content"],
"需求标题": processed_order["title"],
}
add_bittable_record(data)
transfer_work_order(
processed_order["uuid"],
CONFIG.get("newDutyUuid"),
)
# break
messages = "\n".join(messages)
# messages = "\n".join(messages)
if messages.strip():
print("发送飞书通知")
feishu_notify(text=messages)
# if messages.strip():
# print("发送飞书通知")
# feishu_notify(text=messages)
message_without_phone = "\n".join(message_without_phone)
# message_without_phone = "\n".join(message_without_phone)
if message_without_phone.strip():
print("发送飞书通知到内容组")
feishu_notify_to_xbot_content_group(text=message_without_phone)
# if message_without_phone.strip():
# print("发送飞书通知到内容组")
# feishu_notify_to_xbot_content_group(text=message_without_phone)
except requests.RequestException as e:
print(f"请求发生错误: {e}")