Is there a way to set a check for the last word in an on TEXT? Ex:

on *:text:*:#: {
  if (lastword == X) {
   msg # ...
  else return

obviously I know that I could use $1, $2, $3, etc checks... But that's not what I need. Because the text could be anything from $2 to $8 so I need a way to check if the last word is a certain word.