Hello have much experience as a system admin and i have worked with ejabber a lot so I will be able to help you achieve what you want, it can be achievable, i just remembered doing something similar, just a small change in your ejabber config and a script, there are more than one method to even achive this.