[aulite.feishu]
url = "https://open.larksuite.com/open-apis/bot/v2/hook"
access_token = "xxxx"
参数见飞书机器人说明
class Feishu(object):
def __init__(self, access_token, secret, url="https://open.feishu.cn/open-apis/bot/v2/hook/"):
...
def send(self, data):
"""
发送消息
:param data:
:return:
"""
headers = {'Content-Type': 'application/json'}
url = self.get_url()
logger.info(data)
return requests.request("POST", url, headers=headers, data=json.dumps(data), verify=False)
def send_message(self, title, text):
"""
发送消息
:param title: 标题
:param text: 文字
:return:
"""
data = {
"msg_type": "post",
"content": {
"post": {
"zh_cn": {
"title": title,
"content": [[{"tag": "text", "text": text}]
]
}
}
}
}
return self.send(data)
def send_lark_report(self, title, created_at, duration, env, summary, link, is_at_all=False, at_list=[]):
"""
发送lark报告
:param title: 标题
:param created_at: 创建时间
:param duration: 总用时
:param env: 环境
:param summary: 用例执行情况
:param link: 报告地址
:param is_at_all: 是否@所有人
:param at_list: @列表
:return:
"""
相关样式
报告动态配置:
other_elements1 = [{'title': '资金统计', 'fields': [['测试前金额', total_asset_info['faitAssetResult']['totalAsset']]]}]
self.settings.run.other_elements = other_elements1
self.logger.error(self.settings.run.other_elements)
应用机器人配置方法
[aulite.robot]
type = "feishu"
func = "send_lark_report_by_enterprise"
report_link = "xxxxxxx"
[aulite.feishu]
url = "https://open.larksuite.com"
app_id = "xxxxxxx"
app_secret = "xxxxxxx"
app_verification_token = "xxxxxxx"
chat_id = "oc_634bf156ec06eafaac4ed325f64729b3"
获取群ID:
https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/list