-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslackbot.php
33 lines (26 loc) · 872 Bytes
/
slackbot.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
if ($_SERVER["SCRIPT_NAME"] != "/index.php") {
die();
}
/* Slackbot
*/
function slackbot($message) {
$channel = "#sys-admins";
$username = "mymon-bot";
$icon_url = "https://mymon.pkwteile.de/images/mymon_mini.png";
$slackhook = "https://hooks.slack.com/services/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";
$query = "payload={\"channel\": \"$channel\", \"username\": \"$username\", \"text\": \"$message\", \"icon_url\": \"$icon_url\"}";
// Set the cURL options
//die($query);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $slackhook);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute post
$result = curl_exec($ch);
// Close connection
curl_close($ch);
print_r($result);
}
slackbot(";)");