Skip to content

Commit

Permalink
Play sound when Nitro sniped
Browse files Browse the repository at this point in the history
  • Loading branch information
Vedza committed Jan 26, 2021
1 parent cc1df40 commit 89737c6
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.14
require (
github.com/bwmarrin/discordgo v0.22.0
github.com/dgraph-io/ristretto v0.0.3
github.com/faiface/beep v1.0.2
github.com/fatih/color v1.9.0
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/valyala/fasthttp v1.16.0
Expand Down
6 changes: 3 additions & 3 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ if ! .git/hooks/pre-commit; then
fi
rm -rf NitroSniperGo_build_*
mkdir NitroSniperGo_build_win64 NitroSniperGo_build_linux NitroSniperGo_build_mac
env GOOS=windows GOARCH=amd64 go build && cp settings.json NitroSniperGo.exe NitroSniperGo_build_win64
env GOOS=linux go build && cp settings.json NitroSniperGo NitroSniperGo_build_linux
go build && cp NitroSniperGo settings.json NitroSniperGo_build_mac
env GOOS=windows GOARCH=amd64 go build && cp settings.json settings.json NitroSniperGo.exe NitroSniperGo_build_win64
env GOOS=linux go build && cp settings.json settings.json NitroSniperGo NitroSniperGo_build_linux
go build && cp NitroSniperGo settings.json sound.mp3 NitroSniperGo_build_mac
zip -r NitroSniperGo_build_linux NitroSniperGo_build_linux
zip -r NitroSniperGo_build_win64 NitroSniperGo_build_win64
zip -r NitroSniperGo_build_mac NitroSniperGo_build_mac
Expand Down
23 changes: 23 additions & 0 deletions sniper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import (
"fmt"
"github.com/bwmarrin/discordgo"
"github.com/dgraph-io/ristretto"
"github.com/faiface/beep"
"github.com/faiface/beep/mp3"
"github.com/faiface/beep/speaker"
"github.com/fatih/color"
"github.com/kardianos/osext"
"github.com/valyala/fasthttp"
Expand Down Expand Up @@ -647,6 +650,26 @@ func checkCode(bodyString string, code string, user *discordgo.User, guild strin
}
webhookNitro(code, user, guild, channel, 0, response.Message)
} else if strings.Contains(bodyString, "nitro") {
f, err := os.Open("sound.mp3")
if err != nil {
log.Fatal(err)
}

var format beep.Format
sound, format, err := mp3.Decode(f)
if err != nil {
log.Fatal(err)
}
defer sound.Close()

speaker.Init(format.SampleRate, format.SampleRate.N(time.Second/10))

done := make(chan bool)
speaker.Play(beep.Seq(sound, beep.Callback(func() {
done <- true
})))

<-done
nitroType := ""
if reNitroType.Match([]byte(bodyString)) {
nitroType = reNitroType.FindStringSubmatch(bodyString)[1]
Expand Down
Binary file added sound.mp3
Binary file not shown.

0 comments on commit 89737c6

Please sign in to comment.