regexbot: Reindenting code, and removing "invalid thread id" bug

Sometimes regexbot would print "invalid thread id". This occurs when the
raiseExc function is called on the active thread, but by the time the
exception is actually raised, the thread is already dead (hence the id
is no longer valid). So don't raise an exception in this case, and hope
no corner-case bugs occur here. The return values are always checked
anyway, so if it crashes, no bad output should be produced.
Handling reconnect on connection loss