aqjw / tele-step-handler
v1.0.9
2021-09-30 22:47 UTC
Requires
- php: ^7.3|^8.0
- laravel/framework: ^8.12
- westacks/telebot: ^1.8
README
简单的Telegram操作。只需检查这些。
安装
通过Composer安装
composer require aqjw/tele-step-handler
发布配置
php artisan vendor:publish --provider="Aqjw\TeleStepHandler\TeleStepHandlerServiceProvider" --tag="config"
使用方法
创建你的步骤并扩展TeleStepHandlerAbstract
namespace App\Telegram\Steps; use Aqjw\TeleStepHandler\TeleStepHandlerAbstract; use Aqjw\TeleStepHandler\Steps\TeleStepCommand; use Aqjw\TeleStepHandler\Steps\TeleStepButton; class MainSteps extends TeleStepHandlerAbstract { public function handler() { return [ new TeleStepCommand('/start', function () { $this->bot->sendMessage([ 'text' => 'This is start command', 'reply_markup' => [ 'inline_keyboard' => [[['text' => 'Do something', 'callback_data' => 'do_something']]] ] ]); return true; // stop checking other steps }), new TeleStepButton('do_something', function () { $this->bot->sendMessage(['text' => 'Something did']); return true; // stop checking other steps }), ]; } public function trigger($args) { return true; } }
在config/tele_steps.php
中注册你的步骤App\Telegram\Steps\MainSteps::class
'steps' => [ // App\Telegram\Steps\MainSteps::class, ],