Devlog #4: Bot Architecture Cleanup, Persistence & Statistical Charts
Hey everyone! Here’s an update on what I’ve been working on for my project over the past few days.
1. Weekly Activity Charts & Statistics
The biggest new feature is visual weekly statistics! Now users can see a chart/graph of their activity over the course of the week.
- The Challenge: Storing data per user, per specific activity, and across each day of the week.
-
The Solution: Kept it clean and simple using
user_data. - Persistence: Added persistent storage so data isn’t lost on restart. Honestly, I was mind-blown by how powerful Python persistence is—enabling this took literally just a couple of lines of code!
2. Refactoring & Modularizing Code
I decided it was time to break up my codebase into multiple modules/files:
- Separation of Concerns: Initially, my architecture felt a bit messy—files knew too much about each other’s internal logic and were tightly coupled. I refactored the project so that each file and module is more autonomous and encapsulated.
- Troubleshooting: Splitting the code broke a few things at first, but after a bit of debugging, everything is working smoothly now.
3. User Experience & Input Validation
I made several quality-of-life improvements to make the bot feel much more robust:
-
Daily Log Reminders: Added a daily reminder prompting users to log their data for the day. (Note: Users just need to run
/startonce to initialize reminders and resets). - Strict Input Validation: Added input filters. If a step requires a number, invalid text is rejected; if it asks to pick an activity, custom inputs are blocked.
- Python vs C++ appreciation: Coming from a C++ background, it constantly amazes me how complex user interactions and data handling can be written in just a few lines of Python!
What’s Next?
- Writing a solid
README.md - Submitting the project!