🎉 feat: Add funny Egg, Inc. status messages and improve heartbeat#2184
🎉 feat: Add funny Egg, Inc. status messages and improve heartbeat#2184
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds rotating funny status messages related to Egg, Inc. gameplay to the Discord bot's presence and reorganizes the download logic for EggInc artifact configuration data. The changes aim to make the bot more engaging while ensuring proper data loading order.
Changes:
- Added 25 humorous Egg, Inc.-themed status messages that rotate every 2 minutes in the heartbeat
- Reorganized the artifact config download to occur earlier in the execution flow before the artifact data download
- Removed commented-out duplicate code and cleaned up the tasks file
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| main.go | Added math/rand import, changed initial status to "Syncing...", and implemented rotating funny status messages in the heartbeat function |
| src/tasks/tasks.go | Moved downloadEggIncData call for eiafx-config earlier and removed duplicate download/load logic for the same file |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "flag" | ||
| "fmt" | ||
| "log" | ||
| "math/rand" |
There was a problem hiding this comment.
Use "math/rand/v2" instead of "math/rand" to be consistent with the rest of the codebase. All other files in the project that use random numbers import "math/rand/v2", including src/boost/boost.go, src/boost/boost_admin.go, src/boost/contract.go, src/boost/roles.go, and src/tasks/tasks.go. The v2 package provides better defaults and doesn't require manual seeding.
| "math/rand" | |
| "math/rand/v2" |
| funnyPhrases := []string{ | ||
| "Hatching chickens", | ||
| "Shipping eggs", | ||
| "Upgrading silos", | ||
| "Building habs", | ||
| "Swiping drones", | ||
| "Launching rockets", | ||
| "Counting my Golden Eggs", | ||
| "Prestiging", | ||
| "Counting chickens", | ||
| "Running chickens", | ||
| "Tapping silos", | ||
| "Researching eggs", | ||
| "Cracking contracts", | ||
| "Boosting production", | ||
| "Consuming artifacts", | ||
| "Petting chickens", | ||
| "Waiting on my next TE", | ||
| "Calculating optimal boosts", | ||
| "Watching my Egg, Inc. empire grow", | ||
| "Collecting daily rewards", | ||
| "Checking for new contracts", | ||
| "Optimizing my farm layout", | ||
| "Jiggling artifacts", | ||
| "Setting completion alarms", | ||
| } |
There was a problem hiding this comment.
The funnyPhrases slice is recreated on every heartbeat tick (every 2 minutes when counter is even). This is inefficient as it allocates a new slice with 25 strings repeatedly. Consider moving this slice to package-level scope or outside the ticker loop to improve performance and reduce unnecessary allocations.
| log.Printf("Heartbeat error: %v", err) | ||
| err := s.Close() | ||
| if err != nil { | ||
| log.Fatalf("Cannot close the session: %v", err) | ||
| } | ||
| err = s.Open() | ||
| if err != nil { | ||
| log.Fatalf("Cannot open the session: %v", err) |
There was a problem hiding this comment.
The error recovery logic here is problematic. When UpdateStatusComplex fails, the code attempts to close and reopen the Discord session using log.Fatalf(), which will terminate the entire application. This is too aggressive for a heartbeat function that runs in a goroutine. If a status update fails, it shouldn't crash the entire bot. Consider either removing this recovery logic entirely and just logging the error, or implementing a more graceful reconnection strategy without using log.Fatalf().
| log.Printf("Heartbeat error: %v", err) | |
| err := s.Close() | |
| if err != nil { | |
| log.Fatalf("Cannot close the session: %v", err) | |
| } | |
| err = s.Open() | |
| if err != nil { | |
| log.Fatalf("Cannot open the session: %v", err) | |
| log.Printf("Heartbeat error updating status: %v", err) | |
| if cerr := s.Close(); cerr != nil { | |
| log.Printf("Heartbeat error closing session after status failure: %v", cerr) | |
| } | |
| if oerr := s.Open(); oerr != nil { | |
| log.Printf("Heartbeat error reopening session after status failure: %v", oerr) |
| "Setting completion alarms", | ||
| } | ||
|
|
||
| // Randomly choose between showing contract count or a funny phrase |
There was a problem hiding this comment.
The comment says "Randomly choose between showing contract count or a funny phrase" but the code always shows a funny phrase - there's no logic to show contract count. Either update the comment to match the actual behavior or implement the contract count display logic as the comment suggests.
| // Randomly choose between showing contract count or a funny phrase | |
| // Randomly choose a funny status phrase |
No description provided.