2026-06-14 21:47:05 +03:00
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"fmt"
|
|
|
|
|
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
|
|
|
|
|
"github.com/joho/godotenv"
|
|
|
|
|
|
"os"
|
|
|
|
|
|
"log"
|
|
|
|
|
|
"net/http"
|
|
|
|
|
|
"net/url"
|
|
|
|
|
|
"encoding/json"
|
|
|
|
|
|
"crypto/tls"
|
|
|
|
|
|
"time"
|
2026-06-16 01:24:31 +03:00
|
|
|
|
"strconv"
|
2026-06-14 21:47:05 +03:00
|
|
|
|
)
|
|
|
|
|
|
|
2026-06-16 01:24:31 +03:00
|
|
|
|
var userStates = make(map[int64]string)
|
|
|
|
|
|
var Proxy = make(map[int64]string)
|
2026-06-14 21:47:05 +03:00
|
|
|
|
|
|
|
|
|
|
type DataIP struct {
|
|
|
|
|
|
IP string `json:"query"`
|
|
|
|
|
|
Country string `json:"country"`
|
2026-06-16 01:24:31 +03:00
|
|
|
|
ISP string `json:"isp"`
|
2026-06-14 21:47:05 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-16 01:24:31 +03:00
|
|
|
|
func ProxyCheck(proxy string) (bool, string, string, string) {
|
2026-06-14 21:47:05 +03:00
|
|
|
|
proxyurl, err := url.Parse(proxy)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
|
}
|
|
|
|
|
|
transport := &http.Transport{
|
|
|
|
|
|
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
|
|
|
|
|
Proxy: http.ProxyURL(proxyurl),
|
|
|
|
|
|
}
|
|
|
|
|
|
client := &http.Client{
|
|
|
|
|
|
Transport: transport,
|
|
|
|
|
|
Timeout: 20 * time.Second,
|
|
|
|
|
|
}
|
2026-06-16 01:24:31 +03:00
|
|
|
|
req, err := http.NewRequest("GET", "http://ip-api.com/json", nil)
|
2026-06-14 21:47:05 +03:00
|
|
|
|
if err != nil {
|
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
|
}
|
|
|
|
|
|
resp, err := client.Do(req)
|
|
|
|
|
|
if err != nil {
|
2026-06-16 01:24:31 +03:00
|
|
|
|
return false, "Нет", "Нет", "Нет"
|
2026-06-14 21:47:05 +03:00
|
|
|
|
fmt.Println(err)
|
|
|
|
|
|
}
|
2026-06-16 01:24:31 +03:00
|
|
|
|
defer resp.Body.Close()
|
2026-06-14 21:47:05 +03:00
|
|
|
|
var data DataIP
|
2026-06-16 01:24:31 +03:00
|
|
|
|
err = json.NewDecoder(resp.Body).Decode(&data)
|
2026-06-14 21:47:05 +03:00
|
|
|
|
if err != nil {
|
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
|
}
|
2026-06-16 01:24:31 +03:00
|
|
|
|
return true, data.IP, data.Country, data.ISP
|
2026-06-14 21:47:05 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
|
|
err := godotenv.Load()
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
log.Fatalf("%v\n", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
tg := os.Getenv("TG_TOKEN")
|
|
|
|
|
|
bot, err := tgbotapi.NewBotAPI(tg)
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
log.Fatalf("%v\n", err)
|
|
|
|
|
|
}
|
|
|
|
|
|
bot.Debug = true
|
|
|
|
|
|
u := tgbotapi.NewUpdate(0)
|
|
|
|
|
|
u.Timeout = 60
|
|
|
|
|
|
updates := bot.GetUpdatesChan(u)
|
2026-06-16 01:24:31 +03:00
|
|
|
|
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))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|