|
@@ -16,7 +16,7 @@ discard block |
|
|
block discarded – undo |
|
16
|
16
|
$client = new Slack\RealTimeClient($loop); |
|
17
|
17
|
$client->setToken($GLOBALS['config']['slack']['botAuthToken']); |
|
18
|
18
|
|
|
19
|
|
-$client->on('message', function (Slack\Payload $payload) use ($client) { |
|
|
19
|
+$client->on('message', function(Slack\Payload $payload) use ($client) { |
|
20
|
20
|
if ($payload->getData()['user'] !== $GLOBALS['config']['slack']['botId']) { |
|
21
|
21
|
$commandResolver = new \T3Bot\Slack\CommandResolver($payload, $client); |
|
22
|
22
|
$command = $commandResolver->resolveCommand(); |
|
@@ -31,28 +31,28 @@ discard block |
|
|
block discarded – undo |
|
31
|
31
|
} |
|
32
|
32
|
}); |
|
33
|
33
|
|
|
34
|
|
-$client->on('channel_created', function (Slack\Payload $payload) use ($client) { |
|
|
34
|
+$client->on('channel_created', function(Slack\Payload $payload) use ($client) { |
|
35
|
35
|
if ($payload->getData()['user'] !== $GLOBALS['config']['slack']['botId']) { |
|
36
|
36
|
$command = new \T3Bot\Commands\ChannelCommand($payload, $client); |
|
37
|
37
|
$command->processChannelCreated($payload->getData()); |
|
38
|
38
|
} |
|
39
|
39
|
}); |
|
40
|
40
|
|
|
41
|
|
-$client->on('presence_change', function (Slack\Payload $payload) use ($client) { |
|
|
41
|
+$client->on('presence_change', function(Slack\Payload $payload) use ($client) { |
|
42
|
42
|
if ($payload->getData()['user'] !== $GLOBALS['config']['slack']['botId']) { |
|
43
|
43
|
$command = new \T3Bot\Commands\TellCommand($payload, $client); |
|
44
|
44
|
$command->processPresenceChange($payload->getData()['user'], $payload->getData()['presence']); |
|
45
|
45
|
} |
|
46
|
46
|
}); |
|
47
|
47
|
|
|
48
|
|
-$client->connect()->then(function () use ($client) { |
|
|
48
|
+$client->connect()->then(function() use ($client) { |
|
49
|
49
|
echo "Connected!\n"; |
|
50
|
50
|
}); |
|
51
|
51
|
|
|
52
|
52
|
/* @noinspection PhpInternalEntityUsedInspection */ |
|
53
|
53
|
$db = \Doctrine\DBAL\DriverManager::getConnection($GLOBALS['config']['db'], new \Doctrine\DBAL\Configuration()); |
|
54
|
54
|
|
|
55
|
|
-$loop->addPeriodicTimer(5, function () use ($client, $db) { |
|
|
55
|
+$loop->addPeriodicTimer(5, function() use ($client, $db) { |
|
56
|
56
|
$messages = $db->fetchAll('SELECT * FROM messages ORDER BY id ASC'); |
|
57
|
57
|
foreach ($messages as $message) { |
|
58
|
58
|
$data = json_decode($message['message'], true); |