Simplified check for private chat.
Moved check for privmsg to the first statement.
Set exception to reconnect to database if error is raised.