Closed pou closed 9 months ago
i solved this problem like this.
Create The seperate Provider and revrite the original webhook route handler like htis class CustomTelegraphWebhookProvider extends ServiceProvider { /**
/**
then i create the that controller like this (my case) class WebhookController extends Controller { public function handle(Request $request, TelegraphWebhookDispatcher $dispatcher, string $token): Response { $req = $request->all(); $chatId = $req['message']['chat']['id'];
/** @var TelegraphBot $bot */
$bot = TelegraphBot::fromToken($token);
/** @var TelegraphChat $chat */
$chat = $bot->chats()->where('chat_id', $chatId)->first();
$widget = $bot->widget ?? $chat->widget;
/** @var WebhookHandler $handler */
$handler = $dispatcher->dispatch($widget);
$handler->handle($request, $bot);
return \response()->noContent();
}
} how to implement the logic depend on your scenario but the goal is create some resolver that or kernel class with should be responsible for dispatching concrate handler
I'm going to add an option to make it possible to set a specific webhookandler for each bot.
Do you have any wishes?