anchor.diff:      (tryto
        (part *irc-connection* *irc-channel* "Bot shutdown"))
       (tryto (quit *irc-connection* "leaving")))
  +
  +  (defun irc-check-connection ()
  +    (let ((ping-time (get-universal-time)))
  +      (ping *irc-connection* *irc-channel*)
  +      (sleep 20)
  +      (let ((pong-time *pong*))
  +        (if (> (- pong-time ping-time) 20)
  +            (irc-reconnect 1)
  +            nil))))
     )
   ;;;; -----------------------------------------
   
  
positive.code: (progn
    (defparameter *irc-channel* "#midymidybot")
    (defparameter *irc-connection* nil)
  
    (defun correct-cljson-surrogate-pairs (wrong-string)
      (with-output-to-string (out)
  
negative.code: ;;;;------------------------------------------------
  
  (defparameter *tg-loop* nil)
  (defparameter *irc-watcher* nil)
  
  (defun bot-start ()
    (irc-reconnect)
    (setf *irc-watcher*
          (sb-thread:make-thread
           (lambda ()
             (loop
                (sleep 60)
                (irc-check-connection)))))
    (setf *tg-loop* (sb-thread:make-thread #'tg-getupdate-loop)))
  
  (defun bot-halt ()
    (tryto (sb-thread:terminate-thread *tg-loop*))
    (tryto (sb-thread:terminate-thread *irc-watcher*))
    (tryto (irc-shutdown)))
  
  