refactor: split modules and harden scraping workflows

This commit is contained in:
ShukeBta
2026-06-24 11:59:18 +08:00
parent efca3cbe69
commit 192f35d9fa
470 changed files with 47957 additions and 33839 deletions
+11
View File
@@ -55,6 +55,7 @@ func telegramHTTPClient(timeout time.Duration, cfg map[string]string) *http.Clie
func telegramHTTPClients(timeout time.Duration, cfg map[string]string) []*http.Client {
clients := []*http.Client{}
seen := map[string]bool{}
customAPIBase := telegramUsesCustomAPIBase(cfg)
for _, proxyRaw := range telegramProxyCandidates(cfg) {
proxyURL, err := normalizeProxyURL(proxyRaw, "http")
if err != nil || proxyURL == nil {
@@ -70,6 +71,9 @@ func telegramHTTPClients(timeout time.Duration, cfg map[string]string) []*http.C
clients = append(clients, &http.Client{Timeout: timeout, Transport: transport})
}
transport := NewExternalTransport()
if customAPIBase {
transport = NewInternalTransport()
}
clients = append(clients, &http.Client{Timeout: timeout, Transport: transport})
return clients
}
@@ -87,6 +91,9 @@ func telegramProxyCandidates(cfg map[string]string) []string {
if len(out) > 0 {
return out
}
if telegramUsesCustomAPIBase(cfg) {
return out
}
for _, value := range []string{
"http://127.0.0.1:10808",
"http://127.0.0.1:10809",
@@ -102,6 +109,10 @@ func telegramProxyCandidates(cfg map[string]string) []string {
return out
}
func telegramUsesCustomAPIBase(cfg map[string]string) bool {
return telegramAPIBaseURL(cfg) != defaultTelegramAPIBaseURL
}
func telegramPostForm(ctx context.Context, cfg map[string]string, method string, form url.Values, timeout time.Duration) error {
apiURL, err := telegramMethodURL(cfg, cfg["bot_token"], method)
if err != nil {