-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete-message.php
37 lines (29 loc) · 1.04 KB
/
delete-message.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
34
35
36
37
<?php
namespace FC\Slack;
ini_set("display_errors", true);
ini_set("error_reporting", E_ALL);
require 'vendor/autoload.php';
require 'usage/delete-message.usage.php';
try {
// init options
if (!isset($options[OPTION_TOKEN])) { throw new \Exception("Missing option <token>!"); }
else { $appToken = $options[OPTION_TOKEN]; }
if (!isset($options[OPTION_CHANNEL])) { throw new \Exception("Missing option <channel>!"); }
else { $channel = $options[OPTION_CHANNEL]; }
if (!isset($options[OPTION_TIMESTAMP])) { throw new \Exception("Missing option <timestamp>!"); }
else { $timestamp = $options[OPTION_TIMESTAMP]; }
// init Guzzle client
$client = new \GuzzleHttp\Client();
// init Slack App
$slackApp = new \FC\Slack\SlackApp($appToken);
// post message
$r = $slackApp->deleteMessage($client, $channel, $timestamp);
if ($r === true) {
exit(0);
} else {
throw new \Exception("Failed to delete message: $r");
}
} catch (\Exception $e) {
echo $e->getMessage() . PHP_EOL;
exit(1);
}