Understanding token auth via python

Snag - so I realized a constant loop to check if a streamer is online will cause an issue of continually sending a message when they’re online (not only once).

Is there any way of handling this? Is it possible to code in a stop loop when “x” happens and then a resume loop with “x” happens?