update go/tg/l2.go work status 1.0

This commit is contained in:
root 2026-06-16 01:24:31 +03:00
parent 361286c1c8
commit 0336583932
2 changed files with 33 additions and 12 deletions

View file

@ -11,19 +11,19 @@ import (
"encoding/json"
"crypto/tls"
"time"
"strconv"
)
const (
var Step string
var Proxy string
)
var userStates = make(map[int64]string)
var Proxy = make(map[int64]string)
type DataIP struct {
IP string `json:"query"`
Country string `json:"country"`
ISP string `json:"isp"`
}
func ProxyCheck(proxy) (bool, string, string) {
func ProxyCheck(proxy string) (bool, string, string, string) {
proxyurl, err := url.Parse(proxy)
if err != nil {
fmt.Println(err)
@ -36,22 +36,22 @@ func ProxyCheck(proxy) (bool, string, string) {
Transport: transport,
Timeout: 20 * time.Second,
}
req, err := http.NewRequest("GET", "http://ip-api.com", nil)
req, err := http.NewRequest("GET", "http://ip-api.com/json", nil)
if err != nil {
fmt.Println(err)
}
resp, err := client.Do(req)
if err != nil {
return false, "", ""
return false, "Нет", "Нет", "Нет"
fmt.Println(err)
}
defer resp.Body.Close
defer resp.Body.Close()
var data DataIP
err := json.NewDecoder(resp.Body).Decode(&data)
err = json.NewDecoder(resp.Body).Decode(&data)
if err != nil {
fmt.Println(err)
}
return true, data.IP, data.Country
return true, data.IP, data.Country, data.ISP
}
func main() {
@ -68,5 +68,26 @@ func main() {
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
updates := bot.GetUpdatesChan(u)
for update := range updates {}
for update := range updates {
if update.Message == nil { continue }
userID := update.Message.From.ID
if update.Message.IsCommand() {
if update.Message.Command() == "start" {
userStates[userID] = "wating"
bot.Send(tgbotapi.NewMessage(userID, "Введите прокси"))
}
continue
}
switch userStates[userID] {
case "wating":
prox := update.Message.Text
Proxy[userID] = prox
userStates[userID] = ""
status, ip, country, isp := ProxyCheck(Proxy[userID])
stat := strconv.FormatBool(status)
msg := "Работа прокси: " + stat + "\nIP: " + ip + "\nСтрана: " + country + "\nПровайдер: " + isp
bot.Send(tgbotapi.NewMessage(userID, msg))
}
}
}

BIN
go/tg/output/l2 Executable file

Binary file not shown.