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

"User Bot" Deployment suggestions? #85

Open
markfaulk350 opened this issue May 25, 2021 · 5 comments
Open

"User Bot" Deployment suggestions? #85

markfaulk350 opened this issue May 25, 2021 · 5 comments

Comments

@markfaulk350
Copy link

markfaulk350 commented May 25, 2021

Forgive me, I am a new developer. Some of my questions may seem obvious.
I couldn't find any information on deployment best practices.

Do you have advice or examples on how to deploy a "User Bot" in production? Preferably via GCP. AWS & Heroku is also fine.

I chose this npm "telegram" package over the more popular & easier to use npm "telegram-bot-api" because I need to ability to query Telegram group member lists. As far as I know, I am unable to do this via the Bot API.

I understand "User Bots" require a phone number to run, as well as a confirmation code sent to that phone number in order to get the "string session" for the client.

Do you know of any services/websites I can use to generate/rent a new phone number for this? I'd prefer not to use my personal phone number for this "User Bot".

How long does a generated "string session" last? How often will I need to re-enter a confirmation code to keep this bot running?

I am building a live tracking application. In short, my app supports various 3rd party Satellite messengers & beacons and I am using Telegram groups to decide who to show on a map. I need to know all the members of a Telegram group at all times. I plan on querying all members of a group when the bot is first added, then using events to detect when a new user has joined, or an old user has left or been kicked.

Thank you

@painor
Copy link
Member

painor commented May 26, 2021

Hey, I'll try to answer your questions to the best of my ability.

For deploying it doesn't really matter since any VPS that runs 24/7 and has an internet connection should be able to run it granted it has node >12. I've never dealt with GCP or AWS so I couldn't really help you with those.

You are correct you can't query members using the normal bot API.

This library doesn't only run users. it can also run normal bots that you create from @Botfather and those don't need a phone just a token.

Generated sessions can last forever granted you don't log them out from another device. ideally, you should never login more than once.

normal bots when used with this library can query member list using GetParticipants (you should use https://painor.gitbook.io/gramjs/getting-started/available-methods/getting-participants-of-a-group-channel)
for the rest, you can use Raw events and detect when a user was kicked or left. you can use the other library if you're more comfortable with it since Raw events in telegram are a bit hard to deal with.

@markfaulk350
Copy link
Author

Thank you for responding so quickly! You saved me a ton of time & headaches!

I was assuming I had to use a "User Bot" in order to get the participants of a group. Now that I know I can use regular bot credentials it greatly simplifies things.

I am going to try to use this library in conjunction with npm "node-telegram-bot-api". I really only need the ability to getParticipants() from this library. The other npm package has much nicer event handlers and support for webhooks which means I can deploy this on a simple express app in GCP App Engine which doesn't need to poll 24/7.

My only concern is that I will technically have 2 telegram clients connected at the same time using the same bot credentials. Could this be a potential problem or am I overthinking things?

Also is there a way to disable the long list of blue "Debugging" logs in the terminal? Not super important, but I don't know what any of it means so it's just clutter.

@painor
Copy link
Member

painor commented May 27, 2021

the limit for the same telegram clients connecting at the same time is around 9 or 10. after that you won't be getting updates from some of them so you should be fine.

for logging check https://gram.js.org/faq#how-do-i-stop-logging

@isbkch
Copy link

isbkch commented May 28, 2021

Just curious, anyone trying running this within an AWS Lambda function ?

@painor
Copy link
Member

painor commented May 28, 2021

Just curious, anyone trying running this within an AWS Lambda function?

not sure how that would work. to receive updates you'd need to have a connection open so that won't work in lambda as far as I know.

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