korshasa / laravel-telegram-bot
此包已被废弃且不再维护。未建议任何替代包。
最新版本(0.0.1)的此包没有提供许可证信息。
Telegram 机器人
0.0.1
2016-04-19 01:13 UTC
Requires
- korchasa/telegram-php: dev-master
- laravel/framework: ^5.0
- yohang/finite: ^1.1
This package is auto-updated.
Last update: 2021-10-29 01:47:58 UTC
README
<?php namespace App; use korchasa\LaravelTelegramBot\BaseBot; use Finite\State\StateInterface; use korchasa\Telegram\Update; class ExampleBot extends BaseBot { /** * @throws \Finite\Exception\StateException */ public function start() { $this->sendMessage('What\'s your name?'); $this->transition('wait_for_name'); } public function wait_for_name(Update $update) { if ($update === 'korchasa') { $this->transition('special_name_entered'); } else { $this->transition('name_entered'); } } public function hello() { $this->sendMessage('What\'s your name?'); } public function states() { return [ 'start' => [ 'type' => StateInterface::TYPE_INITIAL, ], 'wait_for_name' => [ 'type' => StateInterface::TYPE_NORMAL, ], 'hello' => [ 'type' => StateInterface::TYPE_FINAL, ], ]; } public function transitions() { return [ 'wait_for_name' => ['from' => ['start'], 'to' => 'wait_for_name'], 'name_entered' => ['from' => ['wait_for_name'], 'to' => 'hello'], ]; } }