Skip to content

Commit e2e0a25

Browse files
committed
update
1 parent d65e75a commit e2e0a25

1 file changed

Lines changed: 21 additions & 15 deletions

File tree

web/github.php

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,12 @@ function WildMatch(string $string, string $expression) : bool
193193
function SendToChat(string $Where, array $Payload) : bool
194194
{
195195
global $chatChannels;
196-
$Url = $chatChannels['rocketchat'][$Where];
197-
$c = curl_init();
198-
curl_setopt_array($c, [
196+
$useRC = true;
197+
$useTeams = false;
198+
if ($useRC === true) {
199+
$Url = $chatChannels['rocketchat'][$Where];
200+
$c = curl_init();
201+
curl_setopt_array($c, [
199202
CURLOPT_USERAGENT => 'https://github.com/xPaw/GitHub-WebHook',
200203
CURLOPT_RETURNTRANSFER => true,
201204
CURLOPT_FOLLOWLOCATION => 0,
@@ -207,14 +210,16 @@ function SendToChat(string $Where, array $Payload) : bool
207210
CURLOPT_HTTPHEADER => [
208211
'Content-Type: application/json',
209212
],
210-
]);
211-
curl_exec($c);
212-
$Code = curl_getinfo($c, CURLINFO_HTTP_CODE);
213-
curl_close($c);
214-
//error_log('Rocket Chat HTTP ' . $Code . PHP_EOL);
215-
$c = curl_init();
216-
$Url = $chatChannels['teams'][$Where];
217-
curl_setopt_array($c, [
213+
]);
214+
curl_exec($c);
215+
$Code = curl_getinfo($c, CURLINFO_HTTP_CODE);
216+
curl_close($c);
217+
error_log('Rocket Chat HTTP ' . $Code . PHP_EOL);
218+
}
219+
if ($useTeams === true) {
220+
$c = curl_init();
221+
$Url = $chatChannels['teams'][$Where];
222+
curl_setopt_array($c, [
218223
CURLOPT_USERAGENT => 'https://github.com/xPaw/GitHub-WebHook',
219224
CURLOPT_RETURNTRANSFER => true,
220225
CURLOPT_FOLLOWLOCATION => 0,
@@ -229,10 +234,11 @@ function SendToChat(string $Where, array $Payload) : bool
229234
CURLOPT_HTTPHEADER => [
230235
'Content-Type: application/json',
231236
],
232-
]);
233-
curl_exec($c);
234-
$Code = curl_getinfo($c, CURLINFO_HTTP_CODE);
235-
curl_close($c);
237+
]);
238+
curl_exec($c);
239+
$Code = curl_getinfo($c, CURLINFO_HTTP_CODE);
240+
curl_close($c);
241+
}
236242

237243
return $Code >= 200 && $Code < 300;
238244
}

0 commit comments

Comments
 (0)