Reactor Devlog #2!
What changed?
A lot has happened since my last devlog! I locked in and implemented a bunch of new features, such as:
- error handling!!!
- a WORKING request system to fetch the latest reactor bots to test your bot against
- A bot selector system to add any bot in the CWD or sub-directories into the runner, so you can test your own bot!
- Better UI!!
Woah thats a lot of changes, lemme break it down…
First, the Error Handling!
This one is kinda the most self-explanitory. Basically, The mini_racer engine for python uses an old version of javascript, so some features, like table.at() isnt supported. For table.at() I just added a filler script to the front of the src that defines it, but I can’t realistically catch everything so I a segment in the loading of the bot that runs the code once and checks for a crash or parsing error from the engine and if it fails then it doesn’t import the bot into the bot table. (AI wrote the filler script, but I originally found the bug and also made the error handling section)
Secondly, The Request System!
The request system is arguably the coolest part of this project, but I feel obligated to also explain that some of the request system was assisted by AI (meaning that AI wrote code, I read it, and then reimplemented it with the same general idea) and also ai DID write the leaderboard grabber which just grabs all of the bots’ id’s that I can use to find their links and grab the src, but ONLY the leaderboard parser, not the bot page parser.
Ok, with that out of the way, how does this really work?
well basically I take and parse the current leaderboard stream at defector.hackclub.com/_app/remote/1jsclqx/leaderboardData. Then with that info, I manually take the bot IDs given with that and shove them into this template: https://defector.hackclub.com/bot/(bot ID here). That spits out an HTML page, so I use BeautifulSoup to parse it with this absolute horror of a line: BeautifulSoup(response.text, "html.parser").find_all("pre")[-1].get_text() and extract the source code, before writing them into a file in the botCache folder in the CWD. Then I load the file as normal, just like any other bot.
Thirdly, The Bot Selection System!
The bot selection system works by just replacing the normal leaderboard widget with a DirectoryTree widget and then setting it to show the current working directory, or CWD. I then use a custom sorter script to show only folders and .js files. whenever a JS script is clicked, it just imports it as a normal bot.
Finally, we have UI Improvements!
I added zebra tiling to the leaderboard to make it more readable, made buttons disable themselves during certain actions like disabling the run button when refreshing, and fixed a few little UI bugs.
What’s Next?
well after this I’m going to try to ship, with only 9 days left in Stardance. I Just need to package it with PyPi and I’m done!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.