How to listen to muc participant add/remove event

Hi ,I am developing a bot(using smack library, by referring the ofchat.jar) plugin in openfire. The bot is going to create connection and login with the bot username and password. It’ll fetch all the muc room list it can join and joins each room for listening messages.If any message is recieved it needs to be pushed to a broker.

But, when the chatroom is created from the webclient by a user(general user not a bot) and botuser is added as a participant/member. to that chatroom, I need to automcatically start join and start listening to that message (as all chatrooms are passwordless, I can directly join and listen messages).

So, I though of writing a plugin which listens whenever a participant is added to muc and it should send muc invite to bot user. If any particpant is removed then I should recieve another event and send another event using which I can unjoin the chatroom.

But I am not getting any source for writing this plugin, So is there any source which I can follow or any suggestion So, that my bot can work seamlessly. Any help would be much appreciated.