Skip to content

Commit

Permalink
provide listen command
Browse files Browse the repository at this point in the history
  • Loading branch information
sergix44 committed May 26, 2024
1 parent 3d84bfb commit 5201664
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"require": {
"php": "^8.2",
"nunomaduro/termwind": "^1.0|^2.0",
"nutgram/nutgram": "^4.17.0"
"nutgram/nutgram": "dev-single-polling-update"
},
"require-dev": {
"illuminate/testing": "^9.0|^10.0|^11.0",
Expand Down
25 changes: 25 additions & 0 deletions src/Console/ListenCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace Nutgram\Laravel\Console;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\App;
use SergiX44\Nutgram\Nutgram;
use SergiX44\Nutgram\RunningMode\SingleUpdate;

class ListenCommand extends Command
{
protected $signature = 'nutgram:listen';

protected $description = 'Start the bot for development and reloads after every update.';

public function handle(): void
{
while (true) {
App::forgetInstance(Nutgram::class);
$bot = App::make(Nutgram::class);
$bot->setRunningMode(SingleUpdate::class);
$bot->run();
}
}
}

0 comments on commit 5201664

Please sign in to comment.