Maybe something like this?
Code:
on *:TEXT:*:#: {
  if ($1 == !whois) && ($2) {
    set %noticenick $nick
    if (. isin $2) {
      .enable #who
      .who $2
    }
    else {
      .enable #whois
      .whois $2
    }
  }
}

#who off
raw 352:*: {
  .disable #who
  .notice %noticenick $4 has nick $6
}
raw 315:*: {
  .disable #who
  .notice %noticenick $2 not found
}
#who end

#whois off
raw 311:*: {
  .disable #whois
  .notice %noticenick $2 has ip $4
}
raw 318:*: {
  .disable #whois
  .notice %noticenick $2 not found
}
#whois end