-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 393eea1
Showing
18 changed files
with
1,960 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
* text=auto | ||
|
||
/.github export-ignore | ||
/tests export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
.php_cs export-ignore | ||
.styleci.yml export-ignore | ||
.travis.yml export-ignore | ||
phpunit.xml export-ignore | ||
CHANGELOG.md export-ignore | ||
CONTRIBUTING.md export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.idea/ | ||
.DS_Store | ||
composer.lock | ||
.php_cs.cache | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
// Needed to get styleci-bridge loaded | ||
require_once __DIR__.'/vendor/sllh/php-cs-fixer-styleci-bridge/autoload.php'; | ||
|
||
use SLLH\StyleCIBridge\ConfigBridge; | ||
|
||
return ConfigBridge::create(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
preset: laravel | ||
|
||
enabled: | ||
- unalign_double_arrow | ||
|
||
linting: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
language: php | ||
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
|
||
before_script: | ||
- travis_retry composer self-update --preview | ||
- travis_retry composer install --prefer-dist --no-interaction | ||
|
||
script: | ||
- vendor/bin/phpunit --coverage-clover=coverage.xml | ||
|
||
before_install: | ||
- pip install --user codecov | ||
- echo "extension = redis.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini | ||
|
||
after_success: | ||
- codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Contributing | ||
|
||
Contributions are **welcome** and will be fully **credited**. We accept contributions via Pull Requests on [Github](https://github.com/botman/driver-facebook). | ||
|
||
## Pull Requests | ||
|
||
- **[PSR-2 Coding Standard.](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** The easiest way to apply the conventions is to install [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer). | ||
- **Add tests!** Your patch won't be accepted if it doesn't have tests. | ||
- **Document any change in behaviour.** Make sure the `README.md` and any other relevant documentation are kept up-to-date. | ||
- **Consider our release cycle.** We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. | ||
- **Create feature branches.** Don't ask us to pull from your master branch. | ||
- **One pull request per feature.** If you want to do more than one thing, send multiple pull requests. | ||
- **Send coherent history.** Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting. | ||
|
||
## Running Tests | ||
|
||
```bash | ||
$ phpunit | ||
``` | ||
|
||
|
||
*Happy coding!* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2017 Marcel Pociot | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# BotMan Slack Driver | ||
|
||
BotMan driver to connect Slack with [BotMan](https://github.com/botman/botman) | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Security Vulnerabilities | ||
|
||
If you discover a security vulnerability within BotMan, please send an e-mail to Marcel Pociot at [email protected]. All security vulnerabilities will be promptly addressed. | ||
|
||
## License | ||
|
||
BotMan is free software distributed under the terms of the MIT license. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "botman/driver-slack", | ||
"license": "MIT", | ||
"description": "Slack driver for BotMan", | ||
"keywords": [ | ||
"Bot", | ||
"BotMan", | ||
"Slack" | ||
], | ||
"homepage": "http://github.com/botman/driver-slack", | ||
"authors": [ | ||
{ | ||
"name": "Marcel Pociot", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"php": ">=7.0", | ||
"mpociot/botman": "~2.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "~5.0", | ||
"mockery/mockery": "dev-master", | ||
"mpociot/slack-client": "^0.2.6", | ||
"ext-curl": "*" | ||
}, | ||
"suggest": { | ||
"mpociot/slack-client": "Use the Slack RTM API with BotMan" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"BotMan\\Drivers\\Slack\\": "src/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "vendor/bin/phpunit", | ||
"cs": "php-cs-fixer fix" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"botman/driver-config": [ | ||
"stubs/slack.php" | ||
], | ||
"botman/driver": [ | ||
"BotMan\\Drivers\\Slack\\SlackDriver" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Package Test Suite"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory suffix=".php">src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
<?php | ||
|
||
namespace BotMan\Drivers\Slack\Extensions; | ||
|
||
use BotMan\BotMan\Interfaces\QuestionActionInterface; | ||
|
||
class Menu implements QuestionActionInterface | ||
{ | ||
const DATA_SOURCE_USERS = 'users'; | ||
|
||
const DATA_SOURCE_CHANNELS = 'channels'; | ||
|
||
const DATA_SOURCE_CONVERSATIONS = 'conversations'; | ||
|
||
/** @var string */ | ||
protected $name; | ||
|
||
/** @var string */ | ||
protected $text; | ||
|
||
/** @var array */ | ||
protected $options; | ||
|
||
/** @var array */ | ||
protected $optionGroups; | ||
|
||
/** @var array */ | ||
protected $selectedOptions; | ||
|
||
/** @var string */ | ||
protected $dataSource; | ||
|
||
/** | ||
* @param string $text | ||
* | ||
* @return static | ||
*/ | ||
public static function create($text) | ||
{ | ||
return new static($text); | ||
} | ||
|
||
/** | ||
* @param string $text | ||
*/ | ||
public function __construct($text) | ||
{ | ||
$this->text = $text; | ||
} | ||
|
||
/** | ||
* Set the available menu options. | ||
* | ||
* @param array $options | ||
* @return $this | ||
*/ | ||
public function options(array $options) | ||
{ | ||
$this->options = $options; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the available menu option groups. | ||
* | ||
* @param array $optionGroups | ||
* @return $this | ||
*/ | ||
public function optionGroups(array $optionGroups) | ||
{ | ||
$this->optionGroups = $optionGroups; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the button value. | ||
* | ||
* @param array $options | ||
* @return $this | ||
*/ | ||
public function selectedOptions(array $options) | ||
{ | ||
$this->selectedOptions = $options; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Set the button name (defaults to button text). | ||
* | ||
* @param string $name | ||
* @return $this | ||
*/ | ||
public function name($name) | ||
{ | ||
$this->name = $name; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Populate the menu with all available users. | ||
* | ||
* @return $this | ||
*/ | ||
public function chooseFromUsers() | ||
{ | ||
$this->dataSource = self::DATA_SOURCE_USERS; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Populate the mnue with all available channels. | ||
* | ||
* @return $this | ||
*/ | ||
public function chooseFromChannels() | ||
{ | ||
$this->dataSource = self::DATA_SOURCE_CHANNELS; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Populate the menu with all available conversations. | ||
* | ||
* @return $this | ||
*/ | ||
public function chooseFromConversations() | ||
{ | ||
$this->dataSource = self::DATA_SOURCE_CONVERSATIONS; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function toArray() | ||
{ | ||
$data = [ | ||
'name' => isset($this->name) ? $this->name : $this->text, | ||
'text' => $this->text, | ||
'type' => 'select', | ||
]; | ||
if (count($this->options) > 0) { | ||
$data['options'] = $this->options; | ||
$data['selected_options'] = $this->selectedOptions; | ||
} elseif (count($this->optionGroups) > 0) { | ||
$data['option_groups'] = $this->optionGroups; | ||
$data['selected_options'] = $this->selectedOptions; | ||
} else { | ||
$data['data_source'] = $this->dataSource; | ||
} | ||
|
||
return $data; | ||
} | ||
} |
Oops, something went wrong.