Copying computer code without permission of the author is copyright infringement. Re-distributing protected material is a further form of copyright infringement. It is legal for a person to read publically-available code that is put out on a web page, and you can take factual knowledge that you gain from understanding the code and implement it in your own works, which you can distribute.
Permission comes in two forms: implicit and explicit. When you post some text in the open (no password required), you can read it. Even though reading an online file requires copying it, there is an implicit license to read anything out in the open. There is no implicit right to redistribute: a bot which redistributes your code has infringed your copyright. A bot which correctly checks for explicit permission to redistribute and does not redistribute without permission complies with copyright law.
There have been cases where simple web scraping has been the subject of a lawsuit and where it has been found that "web scraping is legal", but that refers to gathering of information, and not wholesale redistribution of text. If the extent of copying is minimal, it might be possible to defend against copying plus redistribution via a fair use defense. You describe something that does beyond fair use.