2017 © Pedro Peláez
 

library slack-monitor

Slack Real-time monitoring tool

image

howyi/slack-monitor

Slack Real-time monitoring tool

  • Thursday, January 4, 2018
  • by howyi
  • Repository
  • 0 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

slack-monitor

Slack Real-time monitoring tool, (*1)

Start monitoring

// Return the greeting bot

$monitor = new \ServiceMonitor\Slack\SlackMonitor(getenv('SLACK_TOKEN'));

$event = new class extends \ServiceMonitor\Slack\SlackEvent
{
    public function isExecutable(array $value): bool
    {
        if (!isset($value['type']) or !isset($value['text'])) {
            return false;
        }
        return (('message' === $value['type']) and ('hello' === $value['text']));
    }

    public function execute(array $value): void
    {
        echo("User:{$value['user']} greeted :)" . PHP_EOL);

        $this->commander->execute('chat.postMessage', [
            'channel' => $value['channel'],
            'text'    => "Hello, {$value['user']}!"
        ]);
    }
};

$monitor->setEvent($event);
$monitor->start();

The Versions