I feel like the script required would be too large to fit into just one macro. I would just look for an auto-invite addon of some sort.
I've found
AutoInvite by Martag. The only thing is this one invites by whispering a keyword, such as "inv" or "invite."