Skip to content

issue #323 modify getCommandObject and executeCommand for possibility… #689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 15, 2020

Conversation

MicrowaveDev
Copy link
Contributor

For issue: Mess with custom command loading (#323)

Was add possibility to use custom namespace for commands. The code is tested on a real project and works well with two parallel bots. Also backward compatibility is observed

… for possibility to use custom namespaces in commands
@gianlup
Copy link

gianlup commented Nov 27, 2017

Please merge this feature.

@VoDmAl
Copy link

VoDmAl commented Dec 28, 2017

@Jonybang, looks interesting.

But I think all we need is just to use PSR-4.

@jacklul jacklul requested a review from a team March 29, 2018 18:50
@noplanman noplanman changed the base branch from master to develop April 10, 2018 20:23
@noplanman noplanman mentioned this pull request Apr 12, 2018
@edwinfinch
Copy link

Any chance that this will ever be integrated?

Copy link
Member

@noplanman noplanman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've merged the latest develop branch and fixed up some bits of code.

Should be good to go now 🎉

@noplanman
Copy link
Member

@Jonybang and all others here, please excuse my delay on this, just wasn't sure about how the future of the commands system will look like.

So until there is a clearer view, this is a great addition, thanks so much!

@MicrowaveDev
Copy link
Contributor Author

3 years delay, not a big deal though 😁

@noplanman
Copy link
Member

I know, so so sorry 🙈
Can you confirm that the latest version works correctly for you?

Then we can get this merged and I'll release the next version.

@MicrowaveDev
Copy link
Contributor Author

I know, so so sorry 🙈
Can you confirm that the latest version works correctly for you?

Then we can get this merged and I'll release the next version.

sorry, since the last year i haven't my php environment, but if you can run two bots in the same time with this code - everything is okay 😊
I can show example of running two bots - if it will help

@noplanman
Copy link
Member

I can show example of running two bots - if it will help

Yes please!

Do you mean running two bots in parallel, or using the same code but a different config for each bot?

@MicrowaveDev
Copy link
Contributor Author

MicrowaveDev commented Jun 14, 2020

In my laravel api routes i've defined two POST routes:

Route::post('/telegram/' . config('services.telegram.bot_1_token'), function (Request $request) {

    $telegram = new \Longman\TelegramBot\Telegram(config('services.telegram.bot_1_token'), config('services.telegram.bot_1_username'));

    $telegram->addCommandsPath(app_path('Console/Commands/Bot1'));
    $telegram->enableAdmins(config('bot_1.admins'));
    $telegram->handle();
    return 'ok';
});

Route::post('/telegram/' . config('services.telegram.bot_2_token'), function (Request $request) {
    
    $telegram = new \Longman\TelegramBot\Telegram(config('services.telegram.bot_2_token'), config('services.telegram.bot_2_username'));

    $telegram->addCommandsPath(app_path('Console/Commands/Bot2'));
    $telegram->enableAdmins(config('bot_2.admins'));
    $telegram->handle();
    return 'ok';
});

Commands of Bot1 i've stored in app/Console/Commands/Bot1 directory with files CallbackqueryCommand.php, GenericmessageCommand.php and StartCommand.php as well as Bot2 in app/Console/Commands/Bot2 directory

@noplanman
Copy link
Member

@Jonybang Right, thanks. That will still work without problems 👍

@noplanman noplanman merged commit d78e261 into php-telegram-bot:develop Jun 15, 2020
@MicrowaveDev MicrowaveDev deleted the custom_namespace branch June 15, 2020 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants