The only rule is:
Bot must repay that money back in the same transaction.
However now you can use millions of dollars from other people with flash loans to borrow enless ETH and make a HUGE profit.
That means there's a 0% risk of you losing money. You literally can't.
In code, flash loans are just a function from a specific contract.
What you do is deploy a new contract that executes trades between the time you get the flash loan and the time you repay it back.
If for whatever reason something go some wrong assumptions and Bot can't repay that money back, the entire execution will fail and nobody will lose money.
The Smart Contract that allows flash loans will revert and it will be like nothing happened.