-- | Register or unregister the ping timers when we connect/disconnect.
-- Every once in a while we'll send a ping to the server, to see if the
-- connection is still active. We have a timeout timer, 'pingTimeout', that
-- will force a reconnect if it expires. When we receive ping response, we
-- reset the timer, so that it's only triggered if we don't receive a timely
-- response.
managePingTimer :: SEvent -> Bot ()
managePingTimer Connected = do
    tm <- getGlobal' pingTimeoutLen
    runInS tm pingTimeout >>= setGlobal pingTimeoutHandle
    runInS (div tm 3) pingTimer >>= setGlobal pingTimerHandle
managePingTimer :: SEvent -> Bot ()
managePingTimer Connected = do
    tm <- getGlobal' pingTimeoutLen
    runInS tm pingTimeout >>= setGlobal pingTimeoutHandle
    runInS (div tm 3) pingTimer >>= setGlobal pingTimerHandle
managePingTimer Connected = do
    tm <- getGlobal' pingTimeoutLen
    runInS tm pingTimeout >>= setGlobal pingTimeoutHandle
    runInS (div tm 3) pingTimer >>= setGlobal pingTimerHandle