@@ -35,6 +35,8 @@ func SendWebhookAlert(msg string) {
35
35
sendSlackAlert (webhook_url , webhook_proxy , msg )
36
36
} else if alert_sink == "teams" {
37
37
sendTeamsAlert (webhook_url , webhook_proxy , msg )
38
+ } else if alert_sink == "gchat" {
39
+ sendGoogleChatAlert (webhook_url , webhook_proxy , msg )
38
40
} else {
39
41
msg = strings .Replace (msg , "*" , "" , - 1 )
40
42
sendRawWebhookAlert (webhook_url , webhook_proxy , msg )
@@ -98,6 +100,29 @@ func sendTeamsAlert(webhookUrl string, proxy string, msg string) []error {
98
100
return nil
99
101
}
100
102
103
+ // function to send alert to Google Chat webhook
104
+ func sendGoogleChatAlert (webhookUrl string , proxy string , msg string ) []error {
105
+ payload := map [string ]interface {}{
106
+ "text" : msg ,
107
+ }
108
+
109
+ request := gorequest .New ().Proxy (proxy )
110
+ resp , _ , err := request .
111
+ Post (webhookUrl ).
112
+ RedirectPolicy (redirectPolicy ).
113
+ Send (payload ).
114
+ End ()
115
+
116
+ if err != nil {
117
+ return err
118
+ }
119
+ if resp .StatusCode != 200 {
120
+ return []error {fmt .Errorf ("error sending msg. status: %v" , resp .Status )}
121
+ }
122
+
123
+ return nil
124
+ }
125
+
101
126
// function to send alert to webhook service as text
102
127
func sendRawWebhookAlert (webhookUrl string , proxy string , msg string ) []error {
103
128
request := gorequest .New ().Proxy (proxy )
0 commit comments