add some features
continuous-integration/drone/push Build is passing

This commit is contained in:
jianxin committed 2024-06-06 17:59:59 +08:00
1 parent ae3428d422
commit 60d4f2a8e3
3 files changed
+49 -13

No files matched your search

+9 -1
View File
@@ -147,7 +147,15 @@ def do_bitable_record_add(data) -> None:
if "record_edited" in actions_name and action_data["status"] == "optgKzdQp5": if "record_edited" in actions_name and action_data["status"] == "optgKzdQp5":
# 映射对应的用户 id # 映射对应的用户 id
process_new_robot.delay() user_name_id_map = {
"剑心": "0be1759d-d05c-42ad-9ea4-846fc61dc191",
"驿站": "2b694f9f-c3b4-4658-9aad-f714a8ffbc86",
"波音": "668720500393357312",
"虚竹": "620156921033129984",
}
user_id = user_name_id_map.get(action_data["deal_person"])
action_data["deal_person_id"] = user_id
process_new_robot.delay(app_id, app_secret, action_data)
return return
+32 -4
View File
@@ -9,8 +9,8 @@ from celery import Task
from app.utils.utils import * from app.utils.utils import *
from app.utils.yd_utils import get_token, get_activity_info from app.utils.yd_utils import get_token, get_activity_info
from app.utils.feishu import create_doc, get_doc_block, create_doc_block, get_messages from app.utils.feishu import create_doc, get_doc_block, create_doc_block, get_messages
from app.utils.utils import update_record from app.utils.utils import update_record, add_record
from app.utils.yd_utils import new_blank_robot from app.utils.yd_utils import new_blank_robot, new_blank_activity
def parse_history_message(data): def parse_history_message(data):
@@ -275,5 +275,33 @@ def process_new_demand(app_id, app_secret, table_id, record_id, data):
@shared_task(include_result=False) @shared_task(include_result=False)
def process_new_robot(): def process_new_robot(app_id, app_secret, action_data):
new_blank_robot("测试-根据需求生成应用") user_id = action_data["deal_person_id"]
name = action_data["title"]
category = action_data.get("category")
robot_uuid = ""
catagory_table_record = {"UUID": robot_uuid, "名称": name, "分类": "官方指令"}
if category == "opt5xydmUE":
robot_uuid = new_blank_robot(name, user_id)
catagory_table_record["分类"] = "官方应用"
if category == "optRTwYcra":
robot_uuid = new_blank_activity(name, user_id)
catagory_table_record["分类"] = "官方指令"
# 更新多维表格分类管理
table_id = "tbl2GcBvkvMtOBnl"
bitable_token = os.environ["OFFICE_XBOT_BITABLE_TOKEN"]
# 在开发计划中创建记录
client = (
lark.Client.builder()
.app_id(app_id)
.app_secret(app_secret)
.log_level(lark.LogLevel.DEBUG)
.build()
)
add_record(client, bitable_token, table_id, catagory_table_record)
+8 -8
View File
@@ -552,6 +552,8 @@ def new_blank_robot(name="", user_id="80808032853078016"):
time.sleep(5) time.sleep(5)
public.add_developer(new_uuid, user_id) public.add_developer(new_uuid, user_id)
return new_uuid
def new_blank_activity(name="", user_id=""): def new_blank_activity(name="", user_id=""):
"""新建一个指令""" """新建一个指令"""
@@ -560,12 +562,8 @@ def new_blank_activity(name="", user_id=""):
public = Client(public_username, public_password) public = Client(public_username, public_password)
# 1. 设置文件上传模板文件路径 # 1. 设置文件上传模板文件路径
schema_save_path = os.path.join( schema_save_path = os.path.join("/code/app/flow_template/activity", "package.json")
"/home/wn/yd/xybot-private-scripts/data/flow_template/activity", "package.json" package_save_path = os.path.join("/code/app/flow_template/activity", "activity.bot")
)
package_save_path = os.path.join(
"/home/wn/yd/xybot-private-scripts/data/flow_template/activity", "activity.bot"
)
# 3. 公有云生成指令编码和 UUID # 3. 公有云生成指令编码和 UUID
activity_package_code = public.generate_packagename() activity_package_code = public.generate_packagename()
@@ -628,8 +626,10 @@ def new_blank_activity(name="", user_id=""):
SAVE_ROBOT_TEMPLATE["robotPackage"]["externalDependencies"] = [] SAVE_ROBOT_TEMPLATE["robotPackage"]["externalDependencies"] = []
public.save_public(SAVE_ROBOT_TEMPLATE) public.save_public(SAVE_ROBOT_TEMPLATE)
time.sleep(2) time.sleep(10)
public.add_developer(new_robot_uuid, "80808032853078016") public.add_developer(new_robot_uuid, user_id)
return new_robot_uuid
if __name__ == "__main__": if __name__ == "__main__":