|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* T3Bot. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Frank Nägler <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* @link http://www.t3bot.de |
|
8
|
|
|
* @link http://wiki.typo3.org/T3Bot |
|
9
|
|
|
*/ |
|
10
|
|
|
namespace T3Bot\Commands; |
|
11
|
|
|
|
|
12
|
|
|
use Slack\Payload; |
|
13
|
|
|
use Slack\RealTimeClient; |
|
14
|
|
|
use T3Bot\Slack\Message; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class ChannelCommand. |
|
18
|
|
|
* |
|
19
|
|
|
* @property string commandName |
|
20
|
|
|
* @property array helpCommands |
|
21
|
|
|
*/ |
|
22
|
|
|
class ChannelCommand extends AbstractCommand |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* AbstractCommand constructor. |
|
26
|
|
|
* |
|
27
|
|
|
* @param Payload $payload |
|
28
|
|
|
* @param RealTimeClient $client |
|
29
|
|
|
* @param array|null $configuration |
|
30
|
|
|
*/ |
|
31
|
2 |
View Code Duplication |
public function __construct(Payload $payload, RealTimeClient $client, array $configuration = null) |
|
32
|
|
|
{ |
|
33
|
2 |
|
$this->commandName = 'channel'; |
|
34
|
2 |
|
$this->helpCommands = [ |
|
35
|
|
|
'help' => 'shows this help' |
|
36
|
|
|
]; |
|
37
|
2 |
|
parent::__construct($payload, $client, $configuration); |
|
38
|
2 |
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @return bool|string |
|
42
|
|
|
* |
|
43
|
|
|
* @throws \Doctrine\DBAL\DBALException |
|
44
|
|
|
*/ |
|
45
|
1 |
|
public function process() |
|
46
|
|
|
{ |
|
47
|
1 |
|
return false; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* @param array $data |
|
52
|
|
|
* @example $data: |
|
53
|
|
|
* [ |
|
54
|
|
|
* "type": "channel_created", |
|
55
|
|
|
* "channel": { |
|
56
|
|
|
* "id": "C024BE91L", |
|
57
|
|
|
* "name": "fun", |
|
58
|
|
|
* "created": 1360782804, |
|
59
|
|
|
* "creator": "U024BE7LH" |
|
60
|
|
|
* } |
|
61
|
|
|
* ] |
|
62
|
|
|
*/ |
|
63
|
1 |
|
public function processChannelCreated(array $data) |
|
64
|
|
|
{ |
|
65
|
1 |
|
$channel = $data['channel']; |
|
66
|
1 |
|
$message = new Message(); |
|
67
|
1 |
|
$message->setText(sprintf( |
|
68
|
1 |
|
'<@%s> opened channel #%s, join it <#%s>', |
|
69
|
1 |
|
$channel['creator'], |
|
70
|
1 |
|
$channel['name'], |
|
71
|
1 |
|
$channel['id'] |
|
72
|
|
|
)); |
|
73
|
1 |
|
$this->sendResponse($message, null, $this->configuration['slack']['channels']['channelCreated']); |
|
74
|
1 |
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|