The reason it doesn't work is because the "Attempting to rejoin" echo is triggered when you're joining a channel, it's not actually echoed by the /hop command itself... Perhaps you could try something like
on ME:^*:JOIN:#: {
if ($chan(#).status == joining) { echo command here }
haltdef
}
I'm not sure if this will work, it just occured to me, so it's worth a try.