Skip to content
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

Idea for multiple Telegram Bots on a single installation #81

Open
Kianda opened this issue Apr 18, 2019 · 3 comments
Open

Idea for multiple Telegram Bots on a single installation #81

Kianda opened this issue Apr 18, 2019 · 3 comments

Comments

@Kianda
Copy link

Kianda commented Apr 18, 2019

I have multiple small Telegram bots that do, mostly, useless crap.
IMHO have a BotMan studio running for each of my small bots it's an overkill.

I'll try to explain my idea to support multiple telegram bots with one single BotMan Studio installation.
I'm not a Laravel expert and what I would like to know it's if this can be done or maybe there is a better way to do it.

The main issue is the Telegram Token. If we could load dynamically that, then, probably, BotMan Studio would work without any additional trouble.

My idea is this:

Change the Telegram webook from:
https://yourapp.domain/botman
to
https://yourapp.domain/botman/{botusername}

Change the routing to something like this (changing also the $except on class VerifyCsrfToken):
Route::match(['get', 'post'], '/botman/{botusername?}', 'BotManController@handle');

Then on BotMan Studio .env map each token like this:

TELEGRAM_TOKEN_MY_BOT_USERNAME1 = <YOUR-TELEGRAM-TOKEN1-HERE>
TELEGRAM_TOKEN_MY_BOT_USERNAME2 = <YOUR-TELEGRAM-TOKEN2-HERE>
...

At this point when we land on the route https://yourapp.domain/botman/{botusername} we set the {botusername} 'somewhere' and then use that to load the Telegram Token dynamically inside the TelegramDriver class.

Does this make any sense or there is a simpler way to achieve the same result?

Thanks!

@Lloople
Copy link
Contributor

Lloople commented Dec 28, 2019

I don't think this approach would be useful.

The same way you have a different Laravel app for each website you built, you have a different Botman app for each bot you have published. It's the same as a web or api, you need to have your specific models, database, controllers, etc...

If the logic behind your multiple bots are always the same, maybe what you need is just one bot instead.

@Erik-Jonker
Copy link

@Lloople I disagree. Why would you require a Laravel app for each website? What if you build something like a headless CMS that provides data to your multiple websites - or if you simply build multiple "sub" websites on your one Laravel app?

I'm in the same situation where multiple bots are required on the same installation. Why limit the developer?

@Kianda were you able to figure out a possible solution?

@Kianda
Copy link
Author

Kianda commented Jul 21, 2021

@Erik-Jonker yes, managed to get it working on Telegram (vendor/botman/driver-telegram/src/TelegramDriver.php) but the modifications I've made are not super 'clean'!
It was just a "quick fix" to get it working asap on a single install.
I made a patch (cweagans/composer-patches) instead of a fork, I should be able to get it if you want!

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

No branches or pull requests

3 participants