Kinda hard to answer that without writing the code to create the bot, but the summarized steps are in the original comments.
You’re not going to be able to generate all private keys, so you’d have to check them as they’re enumerated. Most likely would need a loop function that generates a private key, then the public keys, then searches for the public key in the ledger, and repeats for all possible private keys.