Skip to content

Commit 1d7cd15

Browse files
authored
Merge pull request #18 from Manifest-Holdings/fix_proxyaddress
Fix proxyaddress feature for twitter
2 parents 6d5a2fe + b2869f4 commit 1d7cd15

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/client-twitter/src/base.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from "agent-twitter-client";
1919
import { EventEmitter } from "events";
2020
import type { TwitterConfig } from "./environment.ts";
21-
import { Agent, fetch, ProxyAgent, setGlobalDispatcher } from "undici";
21+
import { Agent, fetch as undiciFetch, ProxyAgent, setGlobalDispatcher } from "undici";
2222

2323
export function extractAnswer(text: string): string {
2424
const startIndex = text.indexOf("Answer: ") + 8;
@@ -120,7 +120,6 @@ function doLogin(username, cb, proxyUrl?: string, localAddress?: string) {
120120
`${username}:${password}`
121121
).toString("base64")}`;
122122
}
123-
124123
proxyAgent = new ProxyAgent(agentOptions);
125124
}
126125
if (localAddress) {
@@ -131,10 +130,10 @@ function doLogin(username, cb, proxyUrl?: string, localAddress?: string) {
131130
}
132131
try {
133132
const twitterClient = new Scraper({
134-
fetch: fetch,
133+
fetch: undiciFetch,
135134
transform: {
136135
request: (input: any, init: any) => {
137-
if (agent) {
136+
if (proxyAgent || agent) {
138137
return [
139138
input,
140139
{ ...init, dispatcher: proxyAgent ?? agent },

0 commit comments

Comments
 (0)