2025-03-10 08:21:59 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2025-03-10 08:54:10 -07:00
|
|
|
"errors"
|
2025-03-10 08:21:59 -07:00
|
|
|
"fmt"
|
2025-03-10 08:54:10 -07:00
|
|
|
"github.com/BurntSushi/toml"
|
|
|
|
"github.com/sqweek/dialog"
|
2025-03-10 08:21:59 -07:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2025-03-10 08:54:10 -07:00
|
|
|
type Config struct {
|
|
|
|
Log string
|
|
|
|
Apikey string
|
|
|
|
}
|
|
|
|
|
|
|
|
var config Config
|
|
|
|
|
2025-03-12 12:13:01 -07:00
|
|
|
func setupConfig() {
|
2025-03-10 08:54:10 -07:00
|
|
|
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")
|
|
|
|
}
|
2025-03-12 12:13:01 -07:00
|
|
|
} else {
|
|
|
|
log.Fatal(err)
|
2025-03-10 08:54:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2025-03-10 08:21:59 -07:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2025-03-12 12:13:01 -07:00
|
|
|
}
|
2025-03-10 08:21:59 -07:00
|
|
|
|
2025-03-12 12:13:01 -07:00
|
|
|
func main() {
|
|
|
|
setupConfig()
|
2025-03-10 08:21:59 -07:00
|
|
|
|
2025-03-12 12:13:01 -07:00
|
|
|
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")
|
2025-03-10 08:21:59 -07:00
|
|
|
|
2025-03-12 12:13:01 -07:00
|
|
|
var choice int
|
|
|
|
_, err := fmt.Scanf("%d", &choice)
|
2025-03-10 08:21:59 -07:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
2025-03-12 12:13:01 -07:00
|
|
|
switch choice {
|
|
|
|
case 1:
|
|
|
|
gambo()
|
|
|
|
case 2:
|
|
|
|
loot()
|
|
|
|
default:
|
|
|
|
log.Fatalf("%d is not a valid choice, retard\n", choice)
|
2025-03-10 08:54:10 -07:00
|
|
|
}
|
|
|
|
}
|