How to block/redirect specific user agents

Some of our sites have been crawled by the Indylib bot which has been spamming rubbish into URL parameters and generally being a bad bot. What is the best way to block requests from specific user agents?