From 217c6c8baa034969d29befe5c3b14ae483650c42 Mon Sep 17 00:00:00 2001 From: Mitchell Gerber Date: Sat, 13 Jan 2018 12:29:20 -0600 Subject: [PATCH] update dependencies - change imports --- {src/bot => bot}/bot.go | 0 config.template.json | 19 +++++++++---------- {src/config => config}/config.go | 0 src/main.go => main.go | 6 +++--- makefile | 8 ++++---- .../serverstatus.go | 14 +++++++------- 6 files changed, 23 insertions(+), 24 deletions(-) rename {src/bot => bot}/bot.go (100%) rename {src/config => config}/config.go (100%) rename src/main.go => main.go (79%) rename {src/serverstatus => serverstatus}/serverstatus.go (93%) diff --git a/src/bot/bot.go b/bot/bot.go similarity index 100% rename from src/bot/bot.go rename to bot/bot.go diff --git a/config.template.json b/config.template.json index d085bb8..eb0712a 100644 --- a/config.template.json +++ b/config.template.json @@ -1,18 +1,17 @@ { "Token": "your bot token", - "RoomIDList":["room id's goes here"], - "RoleToNotify": "@Elysium", + "RoomIDList":["room id list goes here"], + "RoleToNotify": "@everyone", "GameStatus": "current playing game", "Servers": [ { - "Name": "Felmyst Logon Server", - "Address": "game.felmyst.com", - "Port": 3724 - }, - { - "Name": "Felmyst Game Server", - "Address": "108.61.153.42", - "Port": 8086 + "Name": "Your awesome server", + "Address": "game.server.com", + "Port": 80 + }, { + "Name": "Another awesome server", + "Address": "awesome.server.com", + "Port": 8080 } ] } diff --git a/src/config/config.go b/config/config.go similarity index 100% rename from src/config/config.go rename to config/config.go diff --git a/src/main.go b/main.go similarity index 79% rename from src/main.go rename to main.go index 839ed0c..6a8ea9e 100644 --- a/src/main.go +++ b/main.go @@ -1,9 +1,9 @@ package main import ( - "./bot" - "./config" - "./serverstatus" + "github.com/mgerb/serverstatus/bot" + "github.com/mgerb/serverstatus/config" + "github.com/mgerb/serverstatus/serverstatus" ) // Variables used for command line parameters diff --git a/makefile b/makefile index 7b389db..57eec2f 100644 --- a/makefile +++ b/makefile @@ -2,13 +2,13 @@ run: go run ./src/main.go linux: - go build -o ./dist/ServerStatus-linux ./src/main.go + go build -o ./dist/ServerStatus-linux ./main.go mac: - GOOS=darwin GOARCH=amd64 go build -o ./dist/ServerStatus-mac ./src/main.go + GOOS=darwin GOARCH=amd64 go build -o ./dist/ServerStatus-mac ./main.go windows: - GOOS=windows GOARCH=386 go build -o ./dist/ServerStatus-windows.exe ./src/main.go + GOOS=windows GOARCH=386 go build -o ./dist/ServerStatus-windows.exe ./main.go clean: rm -rf ./dist @@ -16,4 +16,4 @@ clean: copyfiles: cp config.template.json ./dist/config.json -all: linux mac windows copyfiles \ No newline at end of file +all: linux mac windows copyfiles diff --git a/src/serverstatus/serverstatus.go b/serverstatus/serverstatus.go similarity index 93% rename from src/serverstatus/serverstatus.go rename to serverstatus/serverstatus.go index 5cb38c3..d27d867 100644 --- a/src/serverstatus/serverstatus.go +++ b/serverstatus/serverstatus.go @@ -1,13 +1,13 @@ package serverstatus import ( - "../bot" - "../config" - "fmt" - "github.com/anvie/port-scanner" - "github.com/bwmarrin/discordgo" "log" "time" + + "github.com/anvie/port-scanner" + "github.com/bwmarrin/discordgo" + "github.com/mgerb/serverstatus/bot" + "github.com/mgerb/serverstatus/config" ) func Start() { @@ -30,7 +30,7 @@ func scanServers() { //check if server are in config file if len(config.Config.Servers) < 1 { - fmt.Println("No servers in config file.") + log.Println("No servers in config file.") return } @@ -39,7 +39,7 @@ func scanServers() { for index, server := range config.Config.Servers { prevServerUp := server.Online //set value to previous server status - serverScanner := portscanner.NewPortScanner(server.Address, time.Second*2) + serverScanner := portscanner.NewPortScanner(server.Address, time.Second*2, 1) serverUp := serverScanner.IsOpen(server.Port) //check if the port is open if serverUp && serverUp != prevServerUp {