Although it's difficult for us to know every single method Jagex uses to ban bots, I think OPs theory is correct.
Jagex is collecting data on how suspected bots behave with botting worlds. They most likely have a database of the most popular scripts and have an automated system that bans a player once they use a script in the database.
There's evidence of this, many botters have reported getting banned from using a tutorial island script. The only way Jagex can really do this is through the method I listed above.
I don't really know how bots are going to get through this obstacle. A script has to be nearly perfect for it to be hard to detect.