Comments (11)
IMHO there is a difference between "past event" and "current state". E.g. get_chat
existed before the (my_)chat_member
updates existed, so you could/can get the current state without tracking the event. I guess the main point again is, that this info is avaible for bots anyway (through MTProto), so exposing the info through the Bot API doesn't imply that bots would get additional permissions.
from telegram-bot-api.
Thanks for the fast reply!
Flood limits for direct usages of the method aren't increased for bots, so they will exceed the limits very fast.
Just to clarify: Your point is that using getMessage
will lead to hitting flood limits quickly, because there are many other methods that use it internally?
If that the case: Okay, I see the point. On the other hand, users need to care about flood limits anyway.
Accessing local data is much more efficient then sending a request to Bot API and it isn't subject to flood limits.
True. However, there certainly are use cases, where you would only need to call getMessage
once in a while, or only do very few of such calls (like getting the message, the reply_to_message
was a reply to for very specific updates). In those cases, keeping a local database would require much more effort than just accepting to make one more request.
Also, there is currently no proper way to know if a message was already deleted or not: You can try-except copyMessage
or sending a reply to it, but that will lead to a new message, if it in fact still exists. try-excepting getMessage
would be much cleaner.
A similar problem is checking if a user has blocked the bot, btw (currently one has to try-except sendChatAction
or getUserProfilePictures
, if the user should not be pinged in case of success). I'm not too familiar with MTProto, but my guess would be, that this info is somehow available, and it would be a great help, if it was exposed through the API.
from telegram-bot-api.
I suggest method getChatUsers
, And support pagination.
from telegram-bot-api.
Your point is that using getMessage will lead to hitting flood limits quickly, because there are many other methods that use it internally?
Yes. Also, not only getMessage
requests will fail, but a lot of other requests depending on getMessage
, such as deleteMessages
or sendMessage
with reply_to_message_id
, will fail too.
However, there certainly are use cases, where you would only need to call getMessage once in a while, or only do very few of such calls (like getting the message, the reply_to_message was a reply to for very specific updates).
Bots receive all message edits, so it shouldn't need to call getMessage
to receive current state of a message.
Bots receive all replied messages, to this shouldn't be a case either.
Also, there is currently no proper way to know if a message was already deleted or not:
True, but check of message existence by constant regetting of all the messages wouldn't work anyway. Such approach needs enormous number of requests and will immediately lead to exceeding of flood limits.
A similar problem is checking if a user has blocked the bot.
There are no reasons to know that except some statistics. It doesn't matter how often bot checks whether user blocked it, it must handle 403th error, because user can block the bot in-between the check and a request. Bots just need to properly handle 403th error for send message requests.
I'm not too familiar with MTProto, but my guess would be, that this info is somehow available, and it would be a great help,
No, this information isn't available. Moreover, only bots receive an error and non-bots has no way to know that the other user blocked them.
from telegram-bot-api.
All right, thanks for the detailed replies. From my point of view, getMessage
would still be convenient for some use cases, but I can totally understand that if you don't to expose them with the risk of users requesting increased flood limits.
Apart from the two examples getMessage
and bot-was-blocked, the intend of my original post was to have a general look, if some useful information can be exposed by methods allowed for bots anyway. E.g. the Pyrogram docs list that via MTProto bots can retrieve the whole chat members list of either public or private chats and get updates on e.g. user name changes.
Anyway, I'm happy to have the already great Bot API and the updates it already gets. It just seemed to me that it was worth asking, if double checking if some more helpful info could be exposed is an option :) Feel free to close, if you disagree on that.
from telegram-bot-api.
Exposing getMessage
method will affect all the methods, which uses it internally, breaking a lot of other methods when flood limits are exceeded. Flood limits for direct usages of the method aren't increased for bots, so they will exceed the limits very fast.
From the other side, bots receive replied and other context messages directly in updates. There is no place in Bot API where bot receives a message identifier without the message except respose of the method copyMessage
(which is intentional) and the field Message.forward_from_message_id
(where both messages are exactly the same). If the bot received a message identifier previously, it can save all the needed data along with message identifier. Accessing local data is much more efficient then sending a request to Bot API and it isn't subject to flood limits.
from telegram-bot-api.
@Muaath5 Bots should use chat_member
updates instead.
from telegram-bot-api.
@Muaath5 Bots should use
chat_member
updates instead.
@levlam
Why bots should store all updates? It's bad that almost all bots needs a database.
from telegram-bot-api.
@Muaath5
Its much worse to fetch the whole chat member list all the time.
from telegram-bot-api.
I'd like to add that bots are not always added on chat creation and thus can't know about users that are already in the chat, so calling such a method once per chat sounds like a reasonable use case to me. (The (my_)chat_member
updates are awesome btw 🙂 )
from telegram-bot-api.
@Bibo-Joshi Bots aren't supposed to have access to past events. For example, this is never needed to handle chat_member
or my_chat_member
updates.
from telegram-bot-api.
Related Issues (20)
- How can I be sure that Telegram BOT API local server is running properly? HOT 4
- Blockquote HTML syntax issues HOT 1
- pending_update_counts delay HOT 15
- get 404 error on download file! HOT 11
- Bot latency HOT 6
- Failed to forward message: 'Bad Request: message thread not found' HOT 7
- Persistent "ERROR" When Creating Telegram Application HOT 6
- Change the maximum upload size HOT 1
- not able to set more webhooks! HOT 9
- Too few replies to incoming private messages. Conversion is 0% HOT 1
- [ASK] Why not found method getinvoicelink ? HOT 4
- Reactions order in MessageReactionUpdated is not preserved? HOT 3
- message_reaction treats supergroup itselfs reaction as from private chat HOT 2
- Rouse
- Error sending fileid of flac audio in inline request HOT 6
- tele
- Unpaired UTF-8 Bidi Control Character Detected During Build HOT 3
- add WebApp.navigateTo() into the telegram web app js script HOT 1
- Idle Timeout Expired HOT 3
- send file HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram-bot-api.