mirror of
https://github.com/Mibew/mibew_slack.git
synced 2025-01-22 18:10:30 +03:00
commit
1782bd508b
31
Plugin.php
31
Plugin.php
@ -22,28 +22,28 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi
|
|||||||
// Use autoloader for Composer's packages that shipped with the plugin
|
// Use autoloader for Composer's packages that shipped with the plugin
|
||||||
require(__DIR__ . '/vendor/autoload.php');
|
require(__DIR__ . '/vendor/autoload.php');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Initializer
|
* Initializer
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function initialized()
|
public function initialized()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This creates the listener that listens for new
|
* This creates the listener that listens for new
|
||||||
* threads to send out slack notifications
|
* threads to send out slack notifications
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$dispatcher = EventDispatcher::getInstance();
|
$dispatcher = EventDispatcher::getInstance();
|
||||||
$dispatcher->attachListener(Events::THREAD_CREATE, $this, 'sendSlackNotification');
|
$dispatcher->attachListener(Events::THREAD_CREATE, $this, 'sendSlackNotification');
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Sends notification to slack.
|
* Sends notification to slack.
|
||||||
* Sends the date with the username as well
|
* Sends the date with the username as well
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function sendSlackNotification(&$args)
|
public function sendSlackNotification(&$args)
|
||||||
{
|
{
|
||||||
$settings = [
|
$settings = [
|
||||||
@ -54,10 +54,9 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi
|
|||||||
|
|
||||||
$client = new Client($this->config['slack_url'], $settings);
|
$client = new Client($this->config['slack_url'], $settings);
|
||||||
|
|
||||||
|
$client->send(getlocal('You have a new user waiting for a response. Username: {0}', array($args['thread']->userName)));
|
||||||
|
|
||||||
$client->send(getlocal('You have a new message waiting for you!'));
|
return true;
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,10 +24,9 @@ Provides Slack notifications when initiate a chat
|
|||||||
```yaml
|
```yaml
|
||||||
plugins:
|
plugins:
|
||||||
"Mibew:Slack": # Plugin's configurations are described below
|
"Mibew:Slack": # Plugin's configurations are described below
|
||||||
username: "Username you will post as"
|
username: "Username you will post as"
|
||||||
channel: "Channel to post in"
|
channel: "Channel to post in"
|
||||||
slack_url: "Webhook URL from Setup Instructions in Slack"
|
slack_url: "Webhook URL from Setup Instructions in Slack"
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user