diff --git a/main.go b/main.go index 3cfea7a3..588a70d6 100644 --- a/main.go +++ b/main.go @@ -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", + } + + // Randomly choose between showing contract count or a funny phrase + activityName := funnyPhrases[rand.Intn(len(funnyPhrases))] + + err = s.UpdateStatusComplex(discordgo.UpdateStatusData{ + AFK: false, + Activities: []*discordgo.Activity{ + { + Name: activityName, + Type: discordgo.ActivityTypeGame, + }, + }, + Status: string(discordgo.StatusOnline), + }) + if err != nil { + 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) + } + } + } } }() } diff --git a/src/tasks/tasks.go b/src/tasks/tasks.go index 9243ddcb..d2d2e413 100644 --- a/src/tasks/tasks.go +++ b/src/tasks/tasks.go @@ -40,9 +40,6 @@ const eggIncEiAfxConfigFile string = "ttbb-data/ei-afx-config.json" const eggIncEiResearchesURL string = "https://raw.githubusercontent.com/mkmccarty/TokenTimeBoostBot/refs/heads/main/data/ei-researches.json" const eggIncEiResearchesFile string = "ttbb-data/ei-researches.json" -//const eggIncEiAfxConfigURL string = "https://raw.githubusercontent.com/carpetsage/egg/main/wasmegg/_common/eiafx/eiafx-config.json" -//const eggIncEiAfxConfigFile string = "ttbb-data/eiafx-config.json" - const eggIncTokenComplaintsURL string = "https://raw.githubusercontent.com/mkmccarty/TokenTimeBoostBot/refs/heads/main/data/token-complaints.json" const eggIncTokenComplaintsFile string = "ttbb-data/token-complaints.json" @@ -343,6 +340,7 @@ func ExecuteCronJob(s *discordgo.Session) { ei.LoadEventData(eggIncEventsFile) } downloadEggIncData(eggIncDataSchemaURL, eggIncDataSchemaFile) + downloadEggIncData(eggIncEiAfxConfigURL, eggIncEiAfxConfigFile) if !downloadEggIncData(eggIncEiAfxDataURL, eggIncEiAfxDataFile) { err := ei.LoadArtifactsData(eggIncEiAfxDataFile) @@ -351,13 +349,6 @@ func ExecuteCronJob(s *discordgo.Session) { } } - if !downloadEggIncData(eggIncEiAfxConfigURL, eggIncEiAfxConfigFile) { - err := ei.LoadArtifactsData(eggIncEiAfxConfigFile) - if err != nil { - log.Print(err) - } - } - if !downloadEggIncData(eggIncEiResearchesURL, eggIncEiResearchesFile) { ei.LoadResearchData(eggIncEiResearchesFile) }