At least, I've found method to detect those "You have been inactive..." messages.
Just watch for event:
(from wowwiki.com)
"CHAT_MSG_SYSTEM"
Category: Communication
Fired when a system chat message (they are displayed in yellow) is received.
arg1
The content of the chat message.
arg1 formats are found in Blizzard's GlobalStrings.lua. Some possibilities:
ERR_LEARN_RECIPE_S (eg. "You have learned how to create a new item: Bristle Whisker Catfish.")
MARKED_AFK_MESSAGE (eg. "You are now AFK: Away from Keyboard") "
The arg1 is (from GlobalStrings.lua):
utils/xmlbrowser/test/FrameXML/GlobalStrings - World of Warcraft Programming: A Guide and Reference for Creating WoW Addons
IDLE_MESSAGE = "You have been inactive for some time and will be logged out of the game. If you wish to remain logged in, hit the cancel button.";
Bot should take proper action after this event is detected, probably let him logout and wait for 15-30 minutes then relog.
Yeah but red text in middle of screen is present: "Can't do that while stunned." or something like that.