feat(twitter): remove limiter

This commit is contained in:
DIYgod 2024-08-26 15:39:15 +08:00
parent 3ce18dff48
commit ef6448645e
No known key found for this signature in database
1 changed files with 0 additions and 17 deletions

View File

@ -8,7 +8,6 @@ import { CookieAgent, CookieClient } from 'http-cookie-agent/undici';
import { ProxyAgent } from 'undici';
import cache from '@/utils/cache';
import logger from '@/utils/logger';
import { RateLimiterMemory, RateLimiterRedis, RateLimiterQueue } from 'rate-limiter-flexible';
import ofetch from '@/utils/ofetch';
import proxy from '@/utils/proxy';
import login from './login';
@ -16,21 +15,6 @@ import login from './login';
const dispatchers = {};
let authTokenIndex = 0;
const loginLimiter = cache.clients.redisClient
? new RateLimiterRedis({
points: 1,
duration: 1,
execEvenly: true,
storeClient: cache.clients.redisClient,
})
: new RateLimiterMemory({
points: 1,
duration: 1,
execEvenly: true,
});
const loginLimiterQueue = new RateLimiterQueue(loginLimiter);
const token2Cookie = (token) =>
cache.tryGet(`twitter:cookie:${token}`, async () => {
const jar = new CookieJar();
@ -56,7 +40,6 @@ export const twitterGot = async (url, params) => {
if (!config.twitter.authToken) {
throw new ConfigNotFoundError('Twitter cookie is not configured');
}
await loginLimiterQueue.removeTokens(1);
const index = authTokenIndex++ % config.twitter.authToken.length;
const token = config.twitter.authToken[index];