-
Notifications
You must be signed in to change notification settings - Fork 0
/
slack-runner.php
53 lines (40 loc) · 1.45 KB
/
slack-runner.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
require 'vendor/autoload.php';
use Frlnc\Slack\Http\SlackResponseFactory;
use Frlnc\Slack\Http\CurlInteractor;
use Frlnc\Slack\Core\Commander;
use GuzzleHttp\Client;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use WeCamp\Ardo\Arduino\InputPlugin;
use WeCamp\Ardo\Bot;
use WeCamp\Ardo\Cli\Cli;
use WeCamp\Ardo\Messages\Message;
use WeCamp\Ardo\Slack\Plugin\Input;
use WeCamp\Ardo\Slack\Plugin\Output;
use WeCamp\Ardo\Slack\Service\Since;
use WeCamp\Ardo\Slack\Service\Slack;
/* Slack Plugin */
$interactor = new CurlInteractor();
$interactor->setResponseFactory(new SlackResponseFactory);
$slackService = new Slack(new Commander(\getenv('SLACK_TOKEN'), $interactor), 'C09JL3GR0');
$sinceService = new Since('/tmp/since.db');
var_dump($sinceService->getLastTime()->getTime());
$slackInput = new Input($slackService, $sinceService);
$slackOutput = new Output($slackService);
/* Commandline Plugin */
$cli = new Cli(Message::createFromString('Hello World, I am a bot!'));
/* Arduino Plugin */
$httpClient = new Client(['base_uri' => 'http://10.0.0.3']);
$arduinoPlugin = new InputPlugin($httpClient);
/* Logging */
$logger = new Logger('Ardo');
$logger->pushHandler(new StreamHandler('ardoBot.log', Logger::INFO));
/* Feed the Plugins and Logger to Ardo */
$bot = new Bot($logger);
$bot->registerInput($slackInput);
$bot->registerOutput($cli);
$bot->registerOutput($slackOutput);
$bot->registerOutput($arduinoPlugin);
/* Crank the handle. */
$bot->tick();