-
-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Labels
Description
With pre-messages, it's hard for bots to wait for the message to be fully downloaded and then process it.
Up until now, bots used get_next_msgs() to query the unprocessed messages, then set last_msg_id after processing a message to that they won't process it again.
But this will now also return messages that were not fully downloaded.
Some solutions discussed for this are:
- The bot just waits up to ~30s until the message is downloaded, by listening to MsgsChanged events until the download state is done, and doesn't process any messages until then. The MsgsChanged event will contain the correct msg_id. We could easily add a new event for this in core, if that helps.
- This approach doesn't require core changes, but is hacky and can block the whole bot for up to 30s.
- If the sender side always sent the post-message first and the pre-message later (even though then the namings would be very weird), then this would lead to a lot less blocking on the bot side (only if the large message gets lost or gets reordered on the server due to its size)
- We add a new kind of message id that only gets assigned once the message is fully downloaded. We then use this in a new API similar to
get_next_message_ids.- This might lead to message reordering, because core will first fetch all pre-messages and then all post-messages
- We add a table that contains the message ids of all messages that have been downloaded, but not processed yet. We then add an API to query this table, and an API to remove a message id from this table.
- Something like this could as well be implemented outside of core
- This might lead to message reordering, because core will first fetch all pre-messages and then all post-messages
- In core, if
botis true ANDauto-downloadis "all", then we don't add a row into the msgs table until the post-message is received.- This means that we need to reason about multiple download logics in core, but it might be the nicest option from the bot perspective.
Reactions are currently unavailable