You don't need to change much, just add a dynamic component to the %links variable

http://en.wikichip.org/wiki/mirc/variables#Dynamic_Variable_Names