diff --git a/builds/build.go b/builds/build.go index a8de6db..3451d38 100644 --- a/builds/build.go +++ b/builds/build.go @@ -6,6 +6,8 @@ import ( "net/http" "os" "os/exec" + + "github.com/sqweek/dialog" ) func downloadFile(filepath string, url string) (err error) { @@ -53,29 +55,6 @@ func install_nodejs() { } } -func runCommandWithProgress(command string, args ...string) error { - // Create a new command - cmd := exec.Command(command, args...) - - // Redirect standard output and standard error to our program's streams - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - - // Start the command - err := cmd.Start() - if err != nil { - return err - } - - // Wait for the command to complete - err = cmd.Wait() - if err != nil { - return err - } - - return nil -} - func load_url(url string) { _, err := exec.Command("powershell", "-command", "start", url).Output() if err != nil { @@ -98,14 +77,18 @@ func run_bot() { open_ai_url := "https://platform.openai.com/account/api-keys" stability_ai_url := "https://platform.stability.ai/docs/getting-started/authentication" - fmt.Println("\nGet OpenAi API Key from " + open_ai_url) - load_url(open_ai_url) + if dialog.Message("Open Browser to Get OPEN AI API KEY ").YesNo() { + fmt.Println("\nGet OpenAi API Key from " + open_ai_url) + load_url(open_ai_url) + } print("Enter OpenAI API Key OR enter NONE to skip _ ") fmt.Scan(&open_ai_api_key) - fmt.Println("\nGet StabilityAI API Key from " + stability_ai_url) - exec.Command("start", open_ai_url) + if dialog.Message("Open Browser to Get StabilityAI API KEY ").YesNo() { + fmt.Println("\nGet StabilityAI API Key from " + stability_ai_url) + load_url(stability_ai_url) + } print("Enter StabilityAI API Key OR enter NONE to skip _ ") fmt.Scan(&stability_ai_api_key) @@ -119,8 +102,7 @@ func run_bot() { } dot_env.WriteString("OPENAI_API_KEY=" + open_ai_api_key + "\nDREAMSTUDIO_API_KEY=" + stability_ai_api_key) - - defer dot_env.Close() + dot_env.Close() // Setup Guide pwd, _ := os.Getwd() @@ -129,6 +111,11 @@ func run_bot() { println("\r OR ") println("\r - copy & paste following code in command prompt\n pushd D: && cd " + pwd + " && npx yarn dev\n\n") + // clean up directories + + os.Remove("../node-setup.msi") + os.Remove("../whatsapp-ai-bot.zip") + // run bot run_cmd := exec.Command("powershell", "-command", "start", "./setup.exe") @@ -180,7 +167,27 @@ func main() { } run_bot() - - defer os.Remove("./node-setup.msi") - defer os.Remove("./whatsapp-ai-bot.zip") } + +// func runCommandWithProgress(command string, args ...string) error { +// // Create a new command +// cmd := exec.Command(command, args...) + +// // Redirect standard output and standard error to our program's streams +// cmd.Stdout = os.Stdout +// cmd.Stderr = os.Stderr + +// // Start the command +// err := cmd.Start() +// if err != nil { +// return err +// } + +// // Wait for the command to complete +// err = cmd.Wait() +// if err != nil { +// return err +// } + +// return nil +// } diff --git a/builds/go.mod b/builds/go.mod new file mode 100644 index 0000000..8fd3b3d --- /dev/null +++ b/builds/go.mod @@ -0,0 +1,8 @@ +module build + +go 1.20 + +require ( + github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf // indirect + github.com/sqweek/dialog v0.0.0-20220809060634-e981b270ebbf // direct +) diff --git a/builds/go.sum b/builds/go.sum new file mode 100644 index 0000000..2305031 --- /dev/null +++ b/builds/go.sum @@ -0,0 +1,4 @@ +github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf h1:FPsprx82rdrX2jiKyS17BH6IrTmUBYqZa/CXT4uvb+I= +github.com/TheTitanrain/w32 v0.0.0-20180517000239-4f5cfb03fabf/go.mod h1:peYoMncQljjNS6tZwI9WVyQB3qZS6u79/N3mBOcnd3I= +github.com/sqweek/dialog v0.0.0-20220809060634-e981b270ebbf h1:pCxn3BCfu8n8VUhYl4zS1BftoZoYY0J4qVF3dqAQ4aU= +github.com/sqweek/dialog v0.0.0-20220809060634-e981b270ebbf/go.mod h1:/qNPSY91qTz/8TgHEMioAUc6q7+3SOybeKczHMXFcXw= diff --git a/builds/whatsapp-ai-bot_windows.exe b/builds/whatsapp-ai-bot_windows.exe index 2c32e0f..0d6c513 100644 Binary files a/builds/whatsapp-ai-bot_windows.exe and b/builds/whatsapp-ai-bot_windows.exe differ