I have my socket bot scripted so it will rejoin the channel when it gets kicked.

I am using this in my bot's on sockread event:

if ($2 == KICK) { sockwrite -n $sockname JOIN $3 }

The problem with the above code is that the bot is trying to join the channel even when someone else gets kicked from the channel. There's no need for that. How can I determine that it was my socket bot that got kicked, and only respond if it is the socket bot?