2017 © Pedro Peláez
 

library slack-messenger

Library for logging erros and sending messages to Slack

image

coolin/slack-messenger

Library for logging erros and sending messages to Slack

  • Thursday, June 15, 2017
  • by coolin
  • Repository
  • 2 Watchers
  • 0 Stars
  • 389 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 3 % Grown

The README.md

Slack Messenger

Latest Version Issues License, (*1)

This Nette extension package allows you to log your errors and send messages to Slack., (*2)

Instalation

  • Download

composer require coolin/slack-messenger, (*3)

  • Registration
extensions:
    slackMessenger: Coolin\SlackMessenger\SlackExtension
  • Minimal configuration
slackMessenger:
    hook: 'YOUR_SLACK_WEBHOOK'
    channel: '#general'

Configuration

Package contains two services. Messenger and Logger. Both of them can be configured by global settings or, they can have specific configuration. If you use global and specific settings at once, specific setings will be always used., (*4)

slackMessenger:
    hook: 'YOUR_SLACK_WEBHOOK'
    channel: '#globalChannel'
    timeout: 30
    name: 'Slack Bot'
    title: 'globalTitle'
    color: 'globalColor'
    icon: 'globalIcon'
    messenger:
        enable: true
        channel: '#messengerChannel'
        name: 'Slack Bot'
        title: 'messengerTitle'
        color: 'messengerColor'
        icon: 'messengerIcon'
    logger:
        enable: false
        channel: '#loggerChannel'
        name: 'Slack Bot'
        title: 'loggerTitle'
        color: 'loggerColor'
        icon: 'loggerIcon'

Messenger

for sending messages from aplication you have to inject Messenger first. You can do in only if you have enabled Messenger in config.neon, (*5)

  /** @var \Coolin\SlackMessenger\Messenger @inject*/
  public $slack;

  public function send(){
    //variant 1    
    $this->slack->send('Your Message');

    //variant 2
    $message = new \Coolin\SlackMessenger\Message();
    $message->setChannel('#general');
    $message->setName('Awesome Bot');
    $message->setText('I\'m alive!');

    $this->slack->sendMessage($message);
    $this->slack->sendMessage($message, null, self::ALT_SLACK_HOOK); // ignore Slack hook from config and use specific one
  }

In both variants, if you omit some setting, default setting from config.neon will be used instead., (*6)

Formatting

Class Coolin\SlackMessenger\Formater contains basic functions for text formatting., (*7)

$message->setText('Normal text ' . Formatter::bold('bold text'));

The Versions

15/06 2017

dev-master

9999999-dev

Library for logging erros and sending messages to Slack

  Sources   Download

MIT

The Requires

 

logging messaging slack

15/06 2017

0.9.1

0.9.1.0

Library for logging erros and sending messages to Slack

  Sources   Download

MIT

The Requires

 

logging messaging slack

13/12 2016

0.9.0

0.9.0.0

Library for logging erros and sending messages to Slack

  Sources   Download

MIT

The Requires

 

logging messaging slack