-
Notifications
You must be signed in to change notification settings - Fork 3
🎉 feat: Add funny Egg, Inc. status messages and improve heartbeat #2184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ import ( | |||||||||||||||||||||||||||||
| "flag" | ||||||||||||||||||||||||||||||
| "fmt" | ||||||||||||||||||||||||||||||
| "log" | ||||||||||||||||||||||||||||||
| "math/rand" | ||||||||||||||||||||||||||||||
| _ "net/http/pprof" | ||||||||||||||||||||||||||||||
| "os" | ||||||||||||||||||||||||||||||
| "os/signal" | ||||||||||||||||||||||||||||||
|
|
@@ -1029,7 +1030,7 @@ func main() { | |||||||||||||||||||||||||||||
| AFK: false, | ||||||||||||||||||||||||||||||
| Activities: []*discordgo.Activity{ | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| Name: "Egg, Inc.", | ||||||||||||||||||||||||||||||
| Name: "Syncing...", | ||||||||||||||||||||||||||||||
| Type: discordgo.ActivityTypeGame, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||
|
|
@@ -1118,10 +1119,6 @@ func getIntentUserID(i *discordgo.InteractionCreate) string { | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // Heartbeat function to update the modification time of a file at regular intervals | ||||||||||||||||||||||||||||||
| func startHeartbeat(filepath string, interval time.Duration) { | ||||||||||||||||||||||||||||||
| if config.IsDevBot() { | ||||||||||||||||||||||||||||||
| return | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| go func() { | ||||||||||||||||||||||||||||||
| // Create the file if it doesn't exist | ||||||||||||||||||||||||||||||
| if _, err := os.Stat(filepath); os.IsNotExist(err) { | ||||||||||||||||||||||||||||||
|
|
@@ -1133,6 +1130,7 @@ func startHeartbeat(filepath string, interval time.Duration) { | |||||||||||||||||||||||||||||
| _ = f.Close() | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| counter := 0 | ||||||||||||||||||||||||||||||
| ticker := time.NewTicker(interval) | ||||||||||||||||||||||||||||||
| for range ticker.C { | ||||||||||||||||||||||||||||||
| currentTime := time.Now() | ||||||||||||||||||||||||||||||
|
|
@@ -1141,6 +1139,61 @@ func startHeartbeat(filepath string, interval time.Duration) { | |||||||||||||||||||||||||||||
| if err != nil { | ||||||||||||||||||||||||||||||
| log.Printf("Heartbeat error: %v", err) | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| counter++ | ||||||||||||||||||||||||||||||
| if counter%2 == 0 { | ||||||||||||||||||||||||||||||
| // Funny phrases related to Egg, Inc. | ||||||||||||||||||||||||||||||
| 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", | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
Comment on lines
+1145
to
+1170
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // Randomly choose between showing contract count or a funny phrase | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| // Randomly choose between showing contract count or a funny phrase | |
| // Randomly choose a funny status phrase |
Copilot
AI
Feb 13, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.