diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2830b2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bot.token +bingobot diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..f916d5d --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module gitlab.com/whom/bingobot + +go 1.23.2 + +require github.com/bwmarrin/discordgo v0.28.1 + +require ( + github.com/gorilla/websocket v1.4.2 // indirect + golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b // indirect + golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e5a04a3 --- /dev/null +++ b/go.sum @@ -0,0 +1,12 @@ +github.com/bwmarrin/discordgo v0.28.1 h1:gXsuo2GBO7NbR6uqmrrBDplPUx2T3nzu775q/Rd1aG4= +github.com/bwmarrin/discordgo v0.28.1/go.mod h1:NJZpH+1AfhIcyQsPeuBKsUtYrRnjkyu0kIVMCHkZtRY= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= diff --git a/main.go b/main.go new file mode 100644 index 0000000..51e4e7f --- /dev/null +++ b/main.go @@ -0,0 +1,45 @@ +package main + +import ( + "flag" + "log" + "os" + "os/signal" + + "github.com/bwmarrin/discordgo" +) + +var ( + Token = flag.String("token", "", "Bot authentication token") + App = flag.String("app", "", "Application ID") + Guild = flag.String("guild", "", "Guild ID") // Do we want it to be tied to one server? +) + +func main() { + flag.Parse() + if *App == "" { + log.Fatal("application id is not set") + } + + startBot() +} + +func startBot() { + session, _ := discordgo.New("Bot " + *Token) + + err := session.Open() + if err != nil { + log.Fatalf("could not open session: %s", err) + } + + sigch := make(chan os.Signal, 1) + signal.Notify(sigch, os.Interrupt) + <-sigch + + log.Printf("shutting down gracefully...") + + err = session.Close() + if err != nil { + log.Printf("could not close session gracefully: %s", err) + } +} diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..afaaa8a --- /dev/null +++ b/start.sh @@ -0,0 +1,10 @@ +APP_ID=1303795224857804851 + +if [ ! -f "bot.token" ]; then + echo "can't startup: bot.token file missing" + exit 2 +fi + +BOT_TOKEN=$(cat bot.token) + +./bingobot --app ${APP_ID} --token ${BOT_TOKEN} \ No newline at end of file