This issue would likely be triggered when automatically
merging multiple requests into a single one while having
their size exceed 1044456 bytes like SaveFilePartRequest.
This commit avoids such issue by keeping track of the
current size, and if it exceeds the limit, avoid merge.
This has several benefits:
- The message can be resent without re-calling bytes(),
which for some requests may be expensive.
- Converting requests to bytes early lets us detect
errors early, such as OverflowError on bad requests.
- Containers can't exceed 1044456 bytes so knowing their
length is important. This can now be done in O(1).
But also several drawbacks:
- If the object is modified the bytes won't reflect this.
This isn't an issue because it's only done for in msgs.
- Incoming messages can no longer be reconverted into
bytes but this was never needed anyway.
The implications behind this were bigger than expected. The sender
of the message is not actually needed for anything in the bot. The
bot itself may be needed, but only for KeyboardButtonSwitchInline.
Awaiting on a property was strange and only really made sense
in events.NewMessage. Methods like client.get_messages() and
similar return entire custom.Message which won't need to touch
the network, and requiring the await was a poor UX.
This simplifies the flow instead of having separate request/body
attributes, and also means that BinaryReader.tgread_object() can
be used without so many special cases.
This means that the TcpClient and the Connection (currently only
ConnectionTcpFull) will no longer be concerned about handling
errors, but the MTProtoSender will.
The foundation of the library will now be based on asyncio.