Question about replying to messages

Hi, im wondering how to send replies to messages i get. Kinda like a bot. The problem is that i can’t access my connection because its in another class, or at least the way the docs say to do it. I was going to make the conection static but i’d rather not have it static. Any ideas?

Also, the server I’m connecting to has muc, and the way i made my program so far was to use a packet listener because I couldn’t figure out how to use a chat manager with the muc room. I get incoming whispers from the packer listener, but i cant access the connection from inside there.

save the connection to a session then retrieve it.