when a person joins your channel, you would do

/ctcp $nick VERSION

See:
/help on join

then you need to grab that VERSION reply and do something with it.

See:
/help on ctcpreply