I never understood why IRC servers don't just store history and let clients query for it. This seems like a small addition to the protocol that would have made it a lot more pleasant to use. You could always turn the feature off in your channel/server if you want ephemerality.

IRCv3 has an extension that does just that. I've played with it using ergo.

https://ircv3.net/specs/extensions/chathistory

https://github.com/ergochat/ergo