Skip to content

aqjw/tele-step-handle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 

Repository files navigation

Tele Step Handler

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages