MUC's with persistent users

Hello,

I want to create group chats that do not remove the users once they are offline. My goal is to have a chat that once you go inside you always receive the messages that are sent (or until you leave the room manually).

Also I want to detect if a user is not online to receive the message and be able to process the message and for example send it using an SMS, how can I detect this?

I am thinking on writing a plugin to detect the state of the users in the room and process the message manually.