Telegram Bots -- proper way to have the user to wait for an external API response? - telegram

My Telegram Bot will make 1-2 Http API requests to external API. I guess, it may take up to 1-2 minutes to receive an replies.
What's a proper way in Telegram Bots to let the user to wait in such cases? Should I simply send him a text "working.... wait...it may take 1 or several minutes" thus letting him wait and this will be it? Or is there a special way to handle this in Telegram Bots?

Related

Are "user" bots made with telethon allowed on Telegram?

I'm trying to make a bot for telegram using the telethon library. I would like my bot to be able to retrieve all members of any group that it's been added to which is not currently possible with the telegram bot API.
Because of this limitation, I made a new telegram account/app for my bot (using a Google Voice number) to use the python telegram Client, telethon, to gain user level access to the telegram API.
After playing around with it for a bit, I received this error:
telethon.errors.rpcerrorlist.PhoneNumberBannedError: The used phone number has been banned from Telegram and cannot be used anymore. Maybe check https://www.telegram.org/faq_spam (caused by SendCodeRequest)
After trying to login again from my phone I received a similar notification:
This phone number is banned.
I submitted a support ticket which was never responded to, but I was somehow able to login again with the Google Voice number the next day.
My question is: are we allowed to make bots for telegram with user level permissions using the telethon client? I cannot find any explicit rules about this in the telegram API ToS. However, the telethon docs mention in passing:
If your application ever needs user features because bots cannot do certain things, you will be able to easily login as a user and even keep your bot without having to learn a new library.
You're allowed to use any userbots. the ban probability is exact same as of an unofficial app of Telegram in Google play and other platform.
You're however going to be suspected and pre-banned by Telegram if you're from certain countries or you use VOIP phone numbers. Telegram doesn't like such numbers and might require you appeal to unban it manually.
It's fully their decision.
i, have been using my account in forks and userbots, etc.. for many years, so new accounts are suspected to be up to no good and frozen. try with your own number or buy extra legit one.
Telegram is pretty spammy platform and lately they have increased the ban situation.

How telegram bot knows where to respond?

I am using telethon and I have a question that how telegram knows where to send the request?
I have created a bot on telegram. When the user sends a message to the bot then how telegram knows where to redirect that message. I run my program in my local and also on a server. But in the code, we don't mention anything about the server. But the program is working fine on it also.
Need to understand the flow.
Telethon uses what’s called MTProto to communicate with Telegram servers. It connects just like an actual client would (like TDesktop or Webogram, for instance). Once the connection is made, instead of using a phone number, the authentication is made with the bot token. Then, everything else is standard procedure: Ask Telegram for any new message and Telegram responds with all the messages people sent to the bot or to groups your bot is in (if you have that enabled through BotFather). To cut down on traffic, if there’s an open connection, Telegram may send updates automatically.
That’s the general process flow. For more in-depth explanation of how MTProto works, all the technical information is available on their website. The portion about updates is here: https://core.telegram.org/api/updates
Every handler have an arg, i named it here event , e.g:
#client.on(events.NewMessage)
asynce def handler(event):
This event have all information in it, text of message, message id and etc.

Detect stopping of Telegram bot

Does Telegram bot receive any message when the user stops the bot?
When the user starts communication with a bot, he/she sends "/start" command/message to the bot. I would like to know when the user decided to leave.
If you are using InlineKeyboardMarkup I would suggest to use timeout parameter in MessageLoop, so you would know when the user stops sending callback queries.
Something like this
ERROR:root:on_close() called due to IdleTerminate: 1 #1 sec termination
Otherwise there is no method to know that the user has stopped interacting with the bot.

What is rate limit of accessing Telegram bot APIs?

I read in the docs that bot can send:
30 messages/second to different chats
1 message per second to the same chat
20 messages per minute to the same group chat
but this is all about sending messages, what about other endpoints? more specifically getChatMembersCount method?
Thanks
I know it's been a long time, but there's a very good resource now - https://limits.tginfo.me/en. There's a Bots section there. Also if you have time you can send pull request to the github repository - https://github.com/tginfo/Telegram-Limits/

Telegram track forwarding and storing

Short:
Is there any way to detect if a user stores or forwards a message (e.g. a video) in a channel?
Long:
I am completely new to programming for Telegram (although am a programmer). So have no idea about the tools that are provided by Telegram's API. I actually found nothing related to this issue browsing the web and Telegram documentations. So I thought someone might have an experience with it.
The scenario is that a client of mine is running a virtual teaching system on Telegram and her problem is that the added members to the channel are able to forward the teaching videos to other persons out of the channel, who have not actually paid the fee. Now is there any work around on earth for this problem?
You can't track user in Telegram, remember this IM is very care about privacy.
Try making it a Bot rather than a channel, you can create bots with a bot in telegram called botfather search it and consider making a bot instead of a channel
there isn't any way to track users to see if they forward or save the videos.
you can only do one of these:
create a bot using telegram api (not telegram bot api) and then send videos as a self destructing message to each user.
or put the videos on a website which only registered users can login and watch.

Resources