Bot implementation. A few minor issues, but it's working.