From 0878f56c90abd61fd008a15479d0a7f862e567bb Mon Sep 17 00:00:00 2001 From: 6o6ep <97284661+bober757@users.noreply.github.com> Date: Fri, 9 Oct 2026 14:33:50 +0300 Subject: [PATCH] Fix windows bot (#187) * Fix windows bot bot on windows didn't stop creators bot didn't remove tmp files with links * Update main.go --- headless/vk-bot/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/headless/vk-bot/main.go b/headless/vk-bot/main.go index 4ba2a1d..1b37667 100644 --- a/headless/vk-bot/main.go +++ b/headless/vk-bot/main.go @@ -11,6 +11,8 @@ import ( "os/exec" "os/signal" "path/filepath" + "runtime" + "strconv" "strings" "sync" "sync/atomic" @@ -433,11 +435,13 @@ func waitForLink(path string, timeout time.Duration) (string, error) { if err == nil && len(data) > 0 { line := strings.TrimSpace(strings.SplitN(string(data), "\n", 2)[0]) if line != "" { + os.Remove(path) return line, nil } } time.Sleep(500 * time.Millisecond) } + os.Remove(path) return "", fmt.Errorf("creator did not write link within %s", timeout) } @@ -478,7 +482,12 @@ func (b *bot) handleClose(peerID int64, id string) { b.sendMessage(peerID, fmt.Sprintf("Session %s not found", id), mainMenuKeyboard()) return } - sess.cmd.Process.Signal(syscall.SIGTERM) + if runtime.GOOS == "windows" { + args := []string{"/T", "/F", "/PID", strconv.Itoa(sess.cmd.Process.Pid)} + exec.Command("TASKKILL", args...).Start() + } else { + sess.cmd.Process.Signal(syscall.SIGTERM) + } b.sendMessage(peerID, fmt.Sprintf("Session %s closed", id), mainMenuKeyboard()) }