rtippin/messenger-bots
Composer 安装命令:
composer require rtippin/messenger-bots
包简介
Messenger Bots Addon
关键字:
README 文档
README
This package is an addon for rtippin/messenger
Notice
- This package is not required to use the bots feature built into
Messenger. - For more documentation on creating custom bot handlers and packages, visit the official Chat Bots documentation.
Features:
- Ready-made bot action handlers and packages that will plug into the core messenger package.
- Register only the selected bots you wish to use, or let us auto-register all bots we provide.
- Included Bot Handlers:
- Chuck Norris Bot
- Coin Toss Bot
- Commands Bot
- Dad Joke Bot
- Document Finder Bot
- Giphy Bot
- Insult Bot
- Invite Bot
- Joke Bot
- Kanye West Bot
- Knock Bot
- Location Bot
- Nuke Bot
- Random Image Bot
- Reaction Bomb Bot
- Reaction Bot
- Reply Bot
- Rock Paper Scissors Bot
- Roll Bot
- Weather Bot
- Wikipedia Bot
- YoMomma Bot
- YouTube Bot
- Included Packaged Bots:
- Games Package
- Jokester Package
- Neo package
Prerequisites
- To use this package, you must already have the core Messenger package installed.
- You must have bots enabled from within the messenger.php config, or your
.env. - The built-in bot subscriber should also be enabled, unless you wish to register your own event subscriber.
- If the subscriber is queued, be sure to have your queue worker process the defined channel,
messenger-botsis the default.
MESSENGER_BOTS_ENABLED=true
'bots' => [ 'enabled' => env('MESSENGER_BOTS_ENABLED', false), 'subscriber' => [ 'enabled' => true, 'queued' => true, 'channel' => 'messenger-bots', ], ],
Installation
Via Composer
composer require rtippin/messenger-bots
Config
'weather_api_key' => env('BOT_WEATHER_API_KEY'), 'ip_api_key' => env('BOT_LOCATION_API_KEY'), 'youtube_api_key' => env('BOT_YOUTUBE_API_KEY'), 'giphy_api_key' => env('BOT_GIPHY_API_KEY'), 'random_image_url' => env('BOT_RANDOM_IMAGE_URL', 'https://source.unsplash.com/random'), 'auto_register_all' => env('BOT_AUTO_REGISTER_ALL', false),
Publish the config file
php artisan vendor:publish --tag=messenger-bots
- To use weather bot, you must get an API key from Weather API
- To use YouTube bot, you must get an API key from Google Developers Console
- To use Giphy bot, you must get an API key from Giphy
- You may use the location bot without an API key, but for commercial use, you must get an API key from IP API
- Random image bot will use unsplash as the default endpoint to grab a random image from. You may overwrite this endpoint.
Auto Registering Handlers and Packages
- If you plan to use all the bot handlers and packaged bots provided, you can skip registering them manually by enabling the
BOT_AUTO_REGISTER_ALLflag.
Update your .env
BOT_AUTO_REGISTER_ALL=true
Manually Registering Handlers and Bot Packages
- Inside your
MessengerServiceProvider(or any of your providers), you must register all bot handlers and bot packages you want enabled in your application. - You can use the
MessengerBotsfacade to register the handlers and packages. Be sure you do it inside thebootmethod.
Example:
<?php namespace App\Providers; use Illuminate\Support\ServiceProvider; use RTippin\Messenger\Facades\MessengerBots; use RTippin\MessengerBots\Bots\ChuckNorrisBot; use RTippin\MessengerBots\Bots\CoinTossBot; use RTippin\MessengerBots\Bots\CommandsBot; use RTippin\MessengerBots\Bots\DadJokeBot; use RTippin\MessengerBots\Bots\DocumentFinderBot; use RTippin\MessengerBots\Bots\GiphyBot; use RTippin\MessengerBots\Bots\InsultBot; use RTippin\MessengerBots\Bots\InviteBot; use RTippin\MessengerBots\Bots\JokeBot; use RTippin\MessengerBots\Bots\KanyeBot; use RTippin\MessengerBots\Bots\KnockBot; use RTippin\MessengerBots\Bots\LocationBot; use RTippin\MessengerBots\Bots\NukeBot; use RTippin\MessengerBots\Bots\RandomImageBot; use RTippin\MessengerBots\Bots\ReactionBombBot; use RTippin\MessengerBots\Bots\ReactionBot; use RTippin\MessengerBots\Bots\ReplyBot; use RTippin\MessengerBots\Bots\RockPaperScissorsBot; use RTippin\MessengerBots\Bots\RollBot; use RTippin\MessengerBots\Bots\WeatherBot; use RTippin\MessengerBots\Bots\WikiBot; use RTippin\MessengerBots\Bots\YoMommaBot; use RTippin\MessengerBots\Bots\YoutubeBot; use RTippin\MessengerBots\Packages\GamesPackage; use RTippin\MessengerBots\Packages\JokesterPackage; use RTippin\MessengerBots\Packages\NeoPackage; class MessengerServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot(): void { MessengerBots::registerHandlers([ ChuckNorrisBot::class, CoinTossBot::class, CommandsBot::class, DadJokeBot::class, DocumentFinderBot::class, GiphyBot::class, InsultBot::class, InviteBot::class, JokeBot::class, KanyeBot::class, KnockBot::class, LocationBot::class, NukeBot::class, RandomImageBot::class, ReactionBombBot::class, ReactionBot::class, ReplyBot::class, RockPaperScissorsBot::class, RollBot::class, WeatherBot::class, WikiBot::class, YoMommaBot::class, YoutubeBot::class, ]); MessengerBots::registerPackagedBots([ GamesPackage::class, JokesterPackage::class, NeoPackage::class, ]); } }
Registered handlers and packages will now be available to choose when adding an action to a bot or installing a packaged bot.
Credits - Richard Tippin
License - MIT
Please see the license file for more information.
rtippin/messenger-bots 适用场景与选型建议
rtippin/messenger-bots 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.99k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2021 年 06 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Messenger」 「bots」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rtippin/messenger-bots 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rtippin/messenger-bots 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rtippin/messenger-bots 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Enables the creation of cron-jobs tasks to be consumed by symfony/messenger
A handler for Monolog that sends messages to Telegram Channels. Laravel
Messenger functionality for Laravel 5.2.
Craft plugin for detecting bots/crawlers/spiders
统计信息
- 总下载量: 1.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 15
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-20
