mapmyplan / laravel-slack-slash-command-slash-command
让Laravel应用程序响应来自Slack的斜杠命令
Requires
- php: ^7.2|8.*
- guzzlehttp/guzzle: ^6.3|^7.0
- laravel/helpers: ^1.0
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ~3.8.0|^4.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-09-05 08:55:34 UTC
README
此包使您能够轻松让您的Laravel应用程序响应Slack的斜杠命令。
一旦您在Slack上设置了斜杠命令,并将此包安装到Laravel应用程序中,您就可以创建处理斜杠命令的处理程序。以下是一个示例处理程序,它将向Slack发送响应。
namespace App\SlashCommandHandlers; use App\SlashCommand\BaseHandler; use Spatie\SlashCommand\Request; use Spatie\SlashCommand\Response; class CatchAll extends BaseHandler { /** * If this function returns true, the handle method will get called. * * @param \Spatie\SlashCommand\Request $request * * @return bool */ public function canHandle(Request $request): bool { return true; } /** * Handle the given request. Remember that Slack expects a response * within three seconds after the slash command was issued. If * there is more time needed, dispatch a job. * * @param \Spatie\SlashCommand\Request $request * * @return \Spatie\SlashCommand\Response */ public function handle(Request $request): Response { return $this->respondToSlack("You have typed this text: `{$request->text}`"); } }
Spatie是一家位于比利时安特卫普的网页设计公司。您可以在我们的网站上找到我们所有开源项目的概述在这里。
安装
您可以通过composer安装此包
composer require spatie/laravel-slack-slash-command
必须安装此服务提供者。
// config/app.php 'providers' => [ ... Spatie\SlashCommand\SlashCommandServiceProvider::class, ];
您可以使用以下命令发布配置文件:
php artisan vendor:publish --provider="Spatie\SlashCommand\SlashCommandServiceProvider"
这是发布文件的正文内容
return [ /* * At the integration settings over at Slack you can configure the url to which the * slack commands are posted. Specify the path component of that url here. * * For `http://example.com/slack` you would put `slack` here. */ 'url' => 'slack', /* * The token generated by Slack with which to verify if a incoming slash command request is valid. */ 'token' => env('SLACK_SLASH_COMMAND_VERIFICATION_TOKEN'), /* * The signing_secret generated by Slack with which to verify if a incoming slash command request is valid. */ 'signing_secret' => env('SLACK_SIGNING_SECRET'), /* * Verify requests from slack with signing_secret signature */ 'verify_with_signing' => false, /* * The handlers that will process the slash command. We'll call handlers from top to bottom * until the first one whose `canHandle` method returns true. */ 'handlers' => [ //add your own handlers here //this handler will display instructions on how to use the various commands. Spatie\SlashCommand\Handlers\Help::class, //this handler will respond with a `Could not handle command` message. Spatie\SlashCommand\Handlers\CatchAll::class, ], ];
将verify_with_signing
参数更改为使用signing_secret
验证来自Slack的请求
// config/laravel-slack-slash-command.php 'verify_with_signing' => true
文档
您可以在https://docs.spatie.be/laravel-slack-slash-command上找到文档。
如果您在使用此包时遇到困难?发现了一个错误?您有一般性问题或对改进媒体库的建议?请随时在GitHub上创建问题,我们将尽快处理。
变更日志
请参阅CHANGELOG以获取有关最近更改的更多信息。
测试
$ composer test
贡献
请参阅CONTRIBUTING以获取详细信息。
安全
如果您发现任何与安全相关的问题,请通过电子邮件freek@spatie.be联系,而不是使用问题跟踪器。
明信片软件
您可以使用此包,但如果它进入您的生产环境,我们非常感激您从您的家乡给我们寄一张明信片,说明您正在使用我们哪个包。
我们的地址是:Spatie,Samberstraat 69D,2060 安特卫普,比利时。
我们将在我们的公司网站上发布所有收到的明信片。
致谢
消息和附件功能在很大程度上受到了Regan McEntyre的Slack包的启发。
支持我们
Spatie是一家位于比利时安特卫普的网页设计公司。您可以在我们的网站上找到我们所有开源项目的概述在这里。
您的业务依赖于我们的贡献吗?请与我们联系,并在Patreon上支持我们。所有承诺都将专门用于分配人力以维护和新酷功能。
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。