gamboupload/main.go
2025-03-12 12:13:01 -07:00

75 lines
1.3 KiB
Go

package main
import (
"errors"
"fmt"
"github.com/BurntSushi/toml"
"github.com/sqweek/dialog"
"log"
"os"
)
type Config struct {
Log string
Apikey string
}
var config Config
func setupConfig() {
if _, statErr := os.Stat("config.toml"); os.IsNotExist(statErr) {
path, err := dialog.File().Title("Select your WoWChatLog.txt").Load()
if err != nil {
if errors.Is(err, dialog.ErrCancelled) {
log.Fatalf("Cancelled dialog box, exiting")
}
} else {
log.Fatal(err)
}
newConfig := &Config{
Log: path,
Apikey: "12345",
}
file, err := os.Create("config.toml")
if err != nil {
log.Fatal(err)
}
defer file.Close()
encoder := toml.NewEncoder(file)
if err := encoder.Encode(newConfig); err != nil {
log.Fatal(err)
}
}
_, err := toml.DecodeFile("config.toml", &config)
if err != nil {
log.Fatal(err)
}
}
func main() {
setupConfig()
fmt.Println("Select an option (1 or 2):")
fmt.Println("1) Upload a chat log for gambo tracking")
fmt.Println("2) Upload an RCLootCouncil export in csv format")
var choice int
_, err := fmt.Scanf("%d", &choice)
if err != nil {
log.Fatal(err)
}
switch choice {
case 1:
gambo()
case 2:
loot()
default:
log.Fatalf("%d is not a valid choice, retard\n", choice)
}
}