Last active
May 21, 2020 00:02
-
-
Save runo280/c01ca7acd9cf03e6b35487e5945cfcaa to your computer and use it in GitHub Desktop.
Telegram
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"os" | |
"os/exec" | |
"path/filepath" | |
) | |
//go build -ldflags -w | |
func main() { | |
filename := os.Args[0] // get command line first parameter | |
file := filepath.Base(filename) | |
_ = os.Mkdir("t"+file, os.ModePerm) | |
dir, err := filepath.Abs(filepath.Dir(os.Args[0])) | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println(dir) | |
// linux | |
path := fmt.Sprintf("%s/t"+file, dir) | |
telegram := fmt.Sprintf("%s/Telegram", dir) | |
//win | |
//path := fmt.Sprintf("%s\\t"+file, dir) | |
//telegram := fmt.Sprintf("%s\\Telegram", dir) | |
cmd := exec.Command(telegram, "-many", "-workdir", path) | |
cmd.Stdout = os.Stdout | |
cmd.Stderr = os.Stderr | |
err2 := cmd.Run() | |
if err2 != nil { | |
log.Fatalf("cmd.Run() failed with %s\n", err2) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment