It is the protocol's fault, and there is a solution at the protocol level:
https://ircv3.net/specs/extensions/chathistory . So now, you can get messages while offline when using a modern server (eg.
https://ergo.chat/) with a modern client (eg.
https://codeberg.org/emersion/goguma)