User:Krinkle/Notes/BSCBot

This page is about the idea, the bot does not exist (yet). BSC Bot (Bot status checker) would be a bot that periodally checks the status of bots.

Settings

 * : Server to connect to (irc.freenode.net)
 * : Port to connect to at the  (6667)
 * : Nickname to open connection with (BSCBot)
 * : Name of service that handles authentication (NickServ)
 * : Password of the nickname service account
 * : Channelname (including #) of the channel in which problems should be reported (#countervandalism)
 * : Channelname (including #) in which status checks shall be executed. (#cvn-bots)
 * : Time in minutes between checks (the timer will start after the entire test suit is completed, test can never overlap) (5)
 * : Number of seconds before a warning will be sent that a bot is slow. (60)
 * : Number of seconds after a message will be sent that the bot is not responding. (120</tt>)
 * : array of arrays containing the nickname of the bot to check the status of, what to say to start the test, what the response should contain on succes, what the reponse should not contain (optional), what to say to the bot afterwards (optional)
 * Example: ['CVNBot14', 'CVNBot14 bl add sometemporarycodehere', 'sometemporarycodehere', 'error', 'CVNBot14 bl del sometemporarycodehere'];

Start
When booted the bot checks that all settings are valid. A timer for  is started. After the timer runs out the bot loops though. For each of the statuschecker's items the initial message is sent (so all items in the test are running simultaneously).

Loop
After a message is sent a global variable is updated in a way that it indicates this particular bot is running the test and whatever is says in the channel should be processed rather than ignored. Also a timer is started for max_before_fatal+1.
 * Name: bot nickname
 * State: 1 (running), 2 (OK), 3 (ERROR), 4 (WARN), 5 (FATAL)
 * Prevstate: Value of "state" at the end of the previous loop
 * Comment: Response of bot in case of error or succes, otherwise nothing
 * Responsetime: in seconds with 2 digets

onmsg
The  event function will compare the nickname saying something to the global variable.

If it's in it and state is 1 (running)
 * it will see if the message contains the 'succes' pattern
 * if it does it updates state to 2 (OK)
 * If prevstate was 3, 4 or 5
 * "Name is RECOVERY: OK in {timer} seconds response time"
 * If it contains error pattern it updates state to 3 (ERROR).
 * If prevstate was 5
 * "Name is RECOVERY: ERROR in {timer} seconds response time"
 * Else
 * "Name is ERROR: ERROR in {timer} seconds response time"
 * Otherwise message is ignored

max_before_fatal
if it's in the global variable
 * If time is more than max_before_fatal
 * Set state to 5
 * "Name is FATAL with no response in {max_before_fatal} seconds".
 * If time is more than max_before_warn and state is state is not 3 (ERROR) (ie. there was a slow OK)
 * Set state to 4
 * "Name is WARN: {state} in over {max_before_warn} seconds response time".
 * Otherwise it was a fast OK or ERROR.

Commands

 * quit
 * disable Botname
 * enable Botname