Skip to content

Add router #406

Description

@sadegh19b

Hi, I have a suggestion for this great package. It would be great if a router could be added.

I will give some examples:

TelegraphRouter::command('start', [\App\Telegraph\Controllers\BotMenuController::class, 'start']);

TelegraphRouter::callback('cancel', function (\DefStudio\Telegraph\Models\TelegraphChat $chat, \DefStudio\Telegraph\DTO\CallbackQuery $callbackQuery, \Illuminate\Support\Collection $data) {
    // do something
});

TelegraphRouter::message('❌ Cancel', \App\Telegraph\Controllers\BotMenuController::class)->middleware(\App\Telegraph\Middleware\CheckCancel::class);

A router is similar to the Laravel router, which can be used for commands, callback queries, and messages. action it can be called by closure, an invokable controller, or as an array whose first index is the controller and the second index is the method. It can also have middleware like Laravel for more flexibility.

A file called telegraph.php can be created in the routes folder to define the routes there.

If it's implementing these things, it will be great and this package will be more useful.

Activity

  1. fabio-ivona commented on Sep 1, 2023

    @fabio-ivona
    Member

    Hi!

    like this idea, will further explore it in v2 which we'll start developing in the next months

  2. locked and limited conversation to collaborators on Jan 26, 2024
  3. converted this issue into a discussion #488 on Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions