Skip to content

Commit

Permalink
Adds the required Routes to Web.php
Browse files Browse the repository at this point in the history
  • Loading branch information
parsgit committed Oct 14, 2023
1 parent 6bae8ab commit 5e50fc9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/InitBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,25 @@ protected function execute(InputInterface $input, OutputInterface $output)

}

if(File::exists("$app_routes_dir/Web.php")){

$web_route = File::getContent("$app_routes_dir/Web.php");
$web_array = explode("\n", $web_route);

$find_web_route = false;
foreach ($web_array as $key => &$line) {
if(strpos($line, '// Added by botfire')!==false){
$find_web_route = true;
}
}

if($find_web_route == false){
$web_route = $web_route . "\n\n// Added by botfire\n\nRoute::post('bot/run', 'BotController->runCommand');\nRoute::get('bot/webhook/set', 'BotController->setWebhook');\n//Route::get('bot/webhook/get', 'BotController->getWebhook');";
File::putContent("$app_routes_dir/Web.php", $web_route);
$output->writeln("Added required routes to 'Web.php'");
}
}

$output->writeln('');
$output->writeln("Bot initialization completed.");
return Command::SUCCESS;
Expand Down

0 comments on commit 5e50fc9

Please sign in to comment.