diff --git a/cmd/tripbot/tripbot.go b/cmd/tripbot/tripbot.go index fccb96d1..5cbdc7d9 100644 --- a/cmd/tripbot/tripbot.go +++ b/cmd/tripbot/tripbot.go @@ -3,7 +3,6 @@ package main import ( "fmt" "log" - "math/rand" "os" "os/signal" "syscall" @@ -30,7 +29,6 @@ var client *twitch.Client // main performs the various steps to get the bot running func main() { - createRandomSeed() listenForShutdown() initializeErrorLogger() startHttpServer() @@ -44,12 +42,6 @@ func main() { connectToTwitch() } -// createRandomSeed ensures that random numbers will be random -func createRandomSeed() { - // create a brand new random seed - rand.Seed(time.Now().UnixNano()) -} - // listenForShutdown creates a background job that listens for a graceful shutdown request func listenForShutdown() { helpers.WritePidFile(c.Conf.TripbotPidFile) diff --git a/cmd/vlc-server/vlc-server.go b/cmd/vlc-server/vlc-server.go index 86c2174e..1a73b10e 100644 --- a/cmd/vlc-server/vlc-server.go +++ b/cmd/vlc-server/vlc-server.go @@ -2,7 +2,6 @@ package main import ( "log" - "math/rand" "os" "os/signal" "syscall" @@ -24,9 +23,6 @@ func main() { log.Fatal("This doesn't yet work on darwin") } - // create a brand new random seed - rand.Seed(time.Now().UnixNano()) - // write the current pid to a pidfile helpers.WritePidFile(c.Conf.VLCPidFile) diff --git a/pkg/chatbot/chatbot.go b/pkg/chatbot/chatbot.go index 01a1d311..814ac42c 100644 --- a/pkg/chatbot/chatbot.go +++ b/pkg/chatbot/chatbot.go @@ -1,9 +1,9 @@ package chatbot import ( + "crypto/rand" "fmt" "log" - "math/rand" "time" mylog "github.com/adanalife/tripbot/pkg/chatbot/log" @@ -25,7 +25,7 @@ var Uptime time.Time // used to determine which help message to display // randomized so it starts with a new one every restart -var helpIndex = rand.Intn(len(c.HelpMessages)) +var helpIndex = rand.Int(len(c.HelpMessages)) const followerMsg = "Follow the stream to run unlimited commands :)" const subscriberMsg = "You must be a subscriber to run that command :)" diff --git a/pkg/chatbot/commands.go b/pkg/chatbot/commands.go index ca32c31f..e32e1f1a 100644 --- a/pkg/chatbot/commands.go +++ b/pkg/chatbot/commands.go @@ -1,10 +1,10 @@ package chatbot import ( + "crypto/rand" "fmt" "log" "math" - "math/rand" "os" "os/exec" "path/filepath" @@ -57,8 +57,8 @@ func helloCmd(user *users.User, params []string) { // say a random greeting back, with random punctuation greetings := []string{"Hello", "Hey", "Hi"} punctuation := []string{"!", ".", ".", "."} - msg := greetings[rand.Intn(len(greetings))] - msg += punctuation[rand.Intn(len(punctuation))] + msg := greetings[rand.Int(len(greetings))] + msg += punctuation[rand.Int(len(punctuation))] // give a little help message if the user is new if user.CurrentMiles() < 2.0 { diff --git a/pkg/onscreens-server/left-rotator.go b/pkg/onscreens-server/left-rotator.go index 32e504cc..0b8a474c 100644 --- a/pkg/onscreens-server/left-rotator.go +++ b/pkg/onscreens-server/left-rotator.go @@ -1,8 +1,8 @@ package onscreensServer import ( + "crypto/rand" "log" - "math/rand" "path/filepath" "time" @@ -48,7 +48,7 @@ func leftRotatorContent() string { var output string // show a special, very rare message - if rand.Intn(10000) == 0 { + if rand.Int(10000) == 0 { return "You found the rare message! Make a clip for a prize!" } diff --git a/pkg/onscreens-server/right-rotator.go b/pkg/onscreens-server/right-rotator.go index 310b166f..5acf30bd 100644 --- a/pkg/onscreens-server/right-rotator.go +++ b/pkg/onscreens-server/right-rotator.go @@ -1,8 +1,8 @@ package onscreensServer import ( + "crypto/rand" "log" - "math/rand" "path/filepath" "time" diff --git a/pkg/vlc-server/playback.go b/pkg/vlc-server/playback.go index ff63efec..59a52c2c 100644 --- a/pkg/vlc-server/playback.go +++ b/pkg/vlc-server/playback.go @@ -1,8 +1,8 @@ package vlcServer import ( + "crypto/rand" "errors" - "math/rand" "path/filepath" terrors "github.com/adanalife/tripbot/pkg/errors"