Minecraft has an API. If you run your own server you can program it from Python.