Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
<?php
|
|
2 |
/**
|
|
3 |
* This file is part of the Shieldon package.
|
|
4 |
*
|
|
5 |
* (c) Terry L. <contact@terryl.in>
|
|
6 |
*
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
8 |
* file that was distributed with this source code.
|
|
9 |
*
|
|
10 |
* php version 7.1.0
|
|
11 |
*
|
|
12 |
* @category Web-security
|
|
13 |
* @package Shieldon
|
|
14 |
* @author Terry Lin <contact@terryl.in>
|
|
15 |
* @copyright 2019 terrylinooo
|
|
16 |
* @license https://github.com/terrylinooo/shieldon/blob/2.x/LICENSE MIT
|
|
17 |
* @link https://github.com/terrylinooo/shieldon
|
|
18 |
* @see https://shieldon.io
|
|
19 |
*/
|
|
20 |
|
|
21 |
declare(strict_types=1); |
|
22 |
|
|
23 |
namespace Shieldon\Firewall\Panel\Sandbox; |
|
24 |
|
|
25 |
use Shieldon\Messenger\Slack as SlackTest; |
|
26 |
|
|
27 |
/**
|
|
28 |
* The sandbox for Slack.
|
|
29 |
*/
|
|
30 |
class Slack |
|
31 |
{
|
|
32 |
/**
|
|
33 |
* Invoker.
|
|
34 |
*
|
|
35 |
* @param array $args The arguments.
|
|
36 |
*
|
|
37 |
* @return bool
|
|
38 |
*/
|
|
39 | 3 |
public function __invoke(array $args): bool |
40 |
{
|
|
41 | 3 |
return $this->sandbox($args[0], $args[1]); |
42 |
}
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Test Slack.
|
|
46 |
*
|
|
47 |
* @param array $getParams The GET params passed from tryMessenger method.
|
|
48 |
* @param array $message The message title and body.
|
|
49 |
*
|
|
50 |
* @return bool
|
|
51 |
*/
|
|
52 | 3 |
private function sandbox($getParams, $message) |
53 |
{
|
|
54 | 3 |
$botToken = $getParams['botToken'] ?? ''; |
55 | 3 |
$channel = $getParams['channel'] ?? ''; |
56 |
|
|
57 | 3 |
if (!empty($botToken) && !empty($channel)) { |
58 | 3 |
$messenger = new SlackTest($botToken, $channel); |
59 |
|
|
60 | 3 |
if ($messenger->send($message['body'])) { |
61 |
// @codeCoverageIgnoreStart
|
|
62 |
return true; |
|
63 |
// @codeCoverageIgnoreEnd
|
|
64 |
}
|
|
65 |
}
|
|
66 | 3 |
return false; |
67 |
}
|
|
68 |
}
|
Read our documentation on viewing source code .