update go/tg/l2.go work status 1.0
This commit is contained in:
parent
361286c1c8
commit
0336583932
2 changed files with 33 additions and 12 deletions
43
go/tg/l2.go
43
go/tg/l2.go
|
|
@ -11,19 +11,19 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"time"
|
"time"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
var userStates = make(map[int64]string)
|
||||||
var Step string
|
var Proxy = make(map[int64]string)
|
||||||
var Proxy string
|
|
||||||
)
|
|
||||||
|
|
||||||
type DataIP struct {
|
type DataIP struct {
|
||||||
IP string `json:"query"`
|
IP string `json:"query"`
|
||||||
Country string `json:"country"`
|
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)
|
proxyurl, err := url.Parse(proxy)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
|
@ -36,22 +36,22 @@ func ProxyCheck(proxy) (bool, string, string) {
|
||||||
Transport: transport,
|
Transport: transport,
|
||||||
Timeout: 20 * time.Second,
|
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 {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", ""
|
return false, "Нет", "Нет", "Нет"
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close
|
defer resp.Body.Close()
|
||||||
var data DataIP
|
var data DataIP
|
||||||
err := json.NewDecoder(resp.Body).Decode(&data)
|
err = json.NewDecoder(resp.Body).Decode(&data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
return true, data.IP, data.Country
|
return true, data.IP, data.Country, data.ISP
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -68,5 +68,26 @@ func main() {
|
||||||
u := tgbotapi.NewUpdate(0)
|
u := tgbotapi.NewUpdate(0)
|
||||||
u.Timeout = 60
|
u.Timeout = 60
|
||||||
updates := bot.GetUpdatesChan(u)
|
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
BIN
go/tg/output/l2
Executable file
Binary file not shown.
Loading…
Reference in a new issue