aqjw/tele-step-handler

v1.0.9 2021-09-30 22:47 UTC

This package is auto-updated.

Last update: 2024-11-29 06:35:34 UTC


README

Simple telegram actions. Just check this shit.

Installation

Install via composer

composer require aqjw/tele-step-handler

Publish config

php artisan vendor:publish --provider="Aqjw\TeleStepHandler\TeleStepHandlerServiceProvider" --tag="config"

Usage

Create your step and extends with 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;
    }
}

Register your step App\Telegram\Steps\MainSteps::class in config/tele_steps.php

    'steps' => [
        //
        App\Telegram\Steps\MainSteps::class,
    ],

License

MIT