Skip to content

Multiple bots in one application #552

Answered by fabio-ivona
man0so1 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

in this case you should use the main handler to detect the bot and call the dedicated handle:

class MainWebhookHandler extends WebhookHandler
{

    public function handle(Request $request, TelegraphBot $bot): void
    {
        match($bot->id){
             1 => app(Bot1WebhookHandler::class)->handle($request, $bot),
             2 => app(Bot2WebhookHandler::class)->handle($request, $bot),
             3 => app(Bot3WebhookHandler::class)->handle($request, $bot),
             default => parent::handle($request, $bot),
        }
    }

}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@man0so1
Comment options

Answer selected by man0so1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants