Assuming there is a chatbox message, just use the onMessage() method and check for that message and if it appears set youself to stop the script.
public void onMessage(final Message message) {
if (message.getMessage().contains("you wakeup feeling refreshed")) {
//TODO either set a boolean to stop or just stop.
}
}