Refactor ScriptureBot for BotPlatform Decoupling#169
Conversation
- Updated `go.mod` to use `BotPlatform@staging`. - Created `pkg/utils/user.go` to define local `User` struct with state fields (`Action`, `Config`) and database tags, decoupling them from platform `UserData`. - Added helper functions (`GetUserFromSession`, `SetUserAction`, `SetUserConfig`, `GetResourcePath`) to `pkg/utils/user.go` to manage user state and properties in `SessionData.Props`. - Updated `pkg/utils/database.go` to use the local `User` struct for database operations. - Refactored `pkg/bot/telegram.go` to map platform user to local user and store it in `env.Props`. - Updated `pkg/app` logic to use helper functions instead of accessing removed fields (`env.User.Action`, `env.User.Config`, `env.ResourcePath`). - Fixed `pkg/bot/sub.go` to correctly sync platform identity during subscription publishing. - Updated all relevant tests to match the new architecture.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
This PR refactors ScriptureBot to accommodate breaking changes in the
BotPlatformlibrary. TheBotPlatformhas decoupled application state and storage details from the genericUserDataandSessionDatastructures.Key changes:
Userstruct is defined inpkg/utils/user.gowhich includes thedatastoretags and state fields (Action,Config) that were removed fromBotPlatform.ActionandConfigare no longer accessed directly fromenv.User. Instead, they are managed via helper functions that store/retrieve the localUserobject fromenv.Props["User"].env.ResourcePathis replaced byenv.Props["ResourcePath"].Userstruct.RegisterUsermaps the platform identity to the local user and loads state from the database.pkg/bot/sub.gowas updated to ensure the platform user identity is correctly populated from the local user when iterating for subscription broadcasts.All tests have been updated and verified.
PR created automatically by Jules for task 13807978232645792697 started by @julwrites