11from biz .utils .im .dingtalk import DingTalkNotifier
22from biz .utils .im .feishu import FeishuNotifier
3+ from biz .utils .im .webhook import ExtraWebhookNotifier
34from biz .utils .im .wecom import WeComNotifier
45
56
6- def send_notification (content , msg_type = 'text' , title = "通知" , is_at_all = False , project_name = None , url_slug = None ):
7+ def send_notification (content , msg_type = 'text' , title = "通知" , is_at_all = False , project_name = None , url_slug = None ,
8+ webhook_data : dict = {}):
79 """
810 发送通知消息到配置的平台(钉钉和企业微信)
911 :param content: 消息内容
1012 :param msg_type: 消息类型,支持text和markdown
1113 :param title: 消息标题(markdown类型时使用)
1214 :param is_at_all: 是否@所有人
1315 :param url_slug: 由gitlab服务器的url地址(如:http://www.gitlab.com)转换成的slug格式,如: www_gitlab_com
16+ :param webhook_data: push event、merge event的数据内容
1417 """
1518 # 钉钉推送
1619 dingtalk_notifier = DingTalkNotifier ()
1720 dingtalk_notifier .send_message (content = content , msg_type = msg_type , title = title , is_at_all = is_at_all ,
18- project_name = project_name , url_slug = url_slug )
21+ project_name = project_name , url_slug = url_slug )
1922
2023 # 企业微信推送
2124 wecom_notifier = WeComNotifier ()
@@ -26,3 +29,15 @@ def send_notification(content, msg_type='text', title="通知", is_at_all=False,
2629 feishu_notifier = FeishuNotifier ()
2730 feishu_notifier .send_message (content = content , msg_type = msg_type , title = title , is_at_all = is_at_all ,
2831 project_name = project_name , url_slug = url_slug )
32+
33+ # 额外自定义webhook通知
34+ extra_webhook_notifier = ExtraWebhookNotifier ()
35+ system_data = {
36+ "content" : content ,
37+ "msg_type" : msg_type ,
38+ "title" : title ,
39+ "is_at_all" : is_at_all ,
40+ "project_name" : project_name ,
41+ "url_slug" : url_slug
42+ }
43+ extra_webhook_notifier .send_message (system_data = system_data , webhook_data = webhook_data )
0 commit comments