diff --git a/emoji_test.go b/emoji_test.go index 8af652d..8845270 100644 --- a/emoji_test.go +++ b/emoji_test.go @@ -6,16 +6,16 @@ import ( ) func TestEmojiReplacer(t *testing.T) { - emoji = *emojiReplacer() + emoji = emojiReplacer() - if &emoji == nil { + if emoji == nil { t.Error("Emoji replacer is empty") } } func TestEmojiToDescription(t *testing.T) { - if &emoji == nil { - emoji = *emojiReplacer() + if emoji == nil { + emoji = emojiReplacer() } if strings.ToLower(emoji.Replace("🕴️")) != "uomo con completo che levita" { diff --git a/go.mod b/go.mod index ed33cf3..c986d76 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/fsnotify/fsnotify v1.4.10-0.20200417215612-7f4cf4dd2b52 // indirect github.com/goccy/go-json v0.4.11 github.com/goodsign/monday v1.0.1-0.20201007115131-c065b60ec611 - github.com/klauspost/compress v1.11.13 // indirect + github.com/klauspost/compress v1.12.1 // indirect github.com/magiconair/properties v1.8.5 // indirect github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/pelletier/go-toml v1.9.0 // indirect @@ -22,11 +22,11 @@ require ( github.com/valyala/fasthttp v1.23.0 // indirect golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect golang.org/x/mod v0.4.2 // indirect - golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect + golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect golang.org/x/text v0.3.6 golang.org/x/tools v0.1.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect - modernc.org/cc/v3 v3.32.2 // indirect + modernc.org/cc/v3 v3.32.3 // indirect modernc.org/ccgo/v3 v3.9.1 // indirect modernc.org/sqlite v1.10.2 modernc.org/strutil v1.1.1 // indirect diff --git a/go.sum b/go.sum index a8f07d1..d1c6f60 100644 --- a/go.sum +++ b/go.sum @@ -105,6 +105,7 @@ github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrU github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2/go.mod h1:k9Qvh+8juN+UKMCS/3jFtGICgW8O96FVaZsaxdzDkR4= github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a/go.mod h1:ryS0uhF+x9jgbj/N71xsEqODy9BN81/GonCZiOzirOk= github.com/golangci/errcheck v0.0.0-20181223084120-ef45e06d44b6/go.mod h1:DbHgvLiFKX1Sh2T1w8Q/h4NAI8MHIpzCdnBUDTXU3I0= @@ -195,8 +196,8 @@ github.com/klauspost/compress v1.10.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYs github.com/klauspost/compress v1.11.0/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.4/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.8/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.11.13 h1:eSvu8Tmq6j2psUJqJrLcWH6K3w5Dwc+qipbaA6eVEN4= -github.com/klauspost/compress v1.11.13/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.12.1 h1:/+xsCsk06wE38cyiqOR/o7U2fSftcH72xD+BQXmja/g= +github.com/klauspost/compress v1.12.1/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= @@ -484,8 +485,8 @@ golang.org/x/sys v0.0.0-20201126233918-771906719818/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4= +golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -611,8 +612,8 @@ honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt honnef.co/go/tools v0.0.1-2020.1.6/go.mod h1:pyyisuGw24ruLjrr1ddx39WE0y9OooInRzEYLhQB2YY= modernc.org/cc/v3 v3.0.0-20210318154801-be1b88075ae3/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878= modernc.org/cc/v3 v3.32.1/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878= -modernc.org/cc/v3 v3.32.2 h1:x1hq8SHCjUz/p39deT//zl3vGglhnUUr878NqTQxjYQ= -modernc.org/cc/v3 v3.32.2/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878= +modernc.org/cc/v3 v3.32.3 h1:ayXA75logDagLz13TYiKs8tIxR1NPCsTEqmF/VN0EbA= +modernc.org/cc/v3 v3.32.3/go.mod h1:0R6jl1aZlIl2avnYfbfHBS1QB6/f+16mihBObaBC878= modernc.org/ccgo/v3 v3.0.0-20210323214039-32b85d4592bd/go.mod h1:aopmMk0XIpnk9jSIgzkKBPHh2XFLRkoZNG2YwsufRUs= modernc.org/ccgo/v3 v3.9.1 h1:8jy4dzNXGjjZMjNqm0tpk1FOerg0jXOEEXYoNvohoZo= modernc.org/ccgo/v3 v3.9.1/go.mod h1:rQ3qzkBv66+aIdJ5UhbbLIGGMC2q2gzEisBMMyDSOYw= diff --git a/main.go b/main.go index 7f0e0e0..cb85c3d 100644 --- a/main.go +++ b/main.go @@ -26,7 +26,7 @@ var ( // Gods gods = []string{"Dio", "Gesù", "Madonna"} // Emoji replacer - emoji = *emojiReplacer() + emoji = emojiReplacer() // DB connection db *sql.DB ) @@ -58,16 +58,15 @@ func init() { switch strings.ToLower(viper.GetString("loglevel")) { case "logerror", "error": lit.LogLevel = lit.LogError - break + case "logwarning", "warning": lit.LogLevel = lit.LogWarning - break + case "loginformational", "informational": lit.LogLevel = lit.LogInformational - break + case "logdebug", "debug": lit.LogLevel = lit.LogDebug - break } initializeAdjectives() @@ -125,7 +124,7 @@ func main() { // Wait here until CTRL-C or other term signal is received. lit.Info("roberto is now running. Press CTRL-C to exit.") sc := make(chan os.Signal, 1) - signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill) + signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM, os.Interrupt) <-sc // Cleanly close down the Discord session. diff --git a/sound.go b/sound.go index 1afe710..ec7d181 100644 --- a/sound.go +++ b/sound.go @@ -70,7 +70,7 @@ func playSound(s *discordgo.Session, guildID, channelID, fileName string) { // So if the bot gets disconnect/moved we can rejoin the original channel and continue playing songs select { - case _ = <-c1: + case <-c1: break case <-time.After(time.Second / 3): vc, _ = s.ChannelVoiceJoin(guildID, channelID, false, true) @@ -152,8 +152,8 @@ func playSound2(fileName string, vc *discordgo.VoiceConnection, s *discordgo.Ses // So if the bot gets disconnect/moved we can rejoin the original channel and continue playing songs select { - case _ = <-c1: - break + case <-c1: + case <-time.After(time.Second / 3): vc, _ = s.ChannelVoiceJoin(guildID, channelID, false, true) }