D
This commit is contained in:
@@ -6,6 +6,7 @@ import {XApiService} from "./x-api.service";
|
||||
import {XCookieService} from "./x-cookie.service";
|
||||
import {NotifyService} from "../notify.service";
|
||||
import {getAccount} from "./utils/x-headers.util";
|
||||
import {XCacheService} from "../x-cache/x-cache.service";
|
||||
|
||||
export enum SUPPORT_SOCIAL_PROVIDERS {
|
||||
FB = 'fb',
|
||||
@@ -51,6 +52,7 @@ export class XPosterRouterService {
|
||||
private readonly cookieSvc: XCookieService,
|
||||
private readonly browserSvc: XBrowserService,
|
||||
private readonly notifyService: NotifyService,
|
||||
private readonly xCacheService: XCacheService,
|
||||
) {
|
||||
this.X_UNIFIED_ACCOUNT = getAccount();
|
||||
|
||||
@@ -58,8 +60,18 @@ export class XPosterRouterService {
|
||||
|
||||
}
|
||||
|
||||
async verifyCookie(account: XCookieAccount): Promise<any> {
|
||||
return this.cookieSvc.verifyCookie(account, 'UserByScreenName')
|
||||
async verifyCookie(): Promise<any> {
|
||||
// const isAlive = await this.cookieSvc.verifyCookie();
|
||||
const isAlive = await this.browserSvc.verifyCookie();
|
||||
if (!isAlive) {
|
||||
await this.xCacheService.setStateXCookiesIsDie();
|
||||
await this.notifyService.sendUrgentMessageToTele('Cookie đã hết hạn vui lòng cập nhập để sử dụng.')
|
||||
}
|
||||
await this.xCacheService.setStateXCookiesIsSillALive();
|
||||
}
|
||||
|
||||
async canUseXCookies(): Promise<boolean> {
|
||||
return this.xCacheService.isXCookiesAlive()
|
||||
}
|
||||
|
||||
async postTweet(params: {
|
||||
@@ -71,8 +83,18 @@ export class XPosterRouterService {
|
||||
const chain = this.buildChain(strategy, account);
|
||||
const attempts: RouterResult['attempts'] = [];
|
||||
|
||||
const canUseCookie = this.canUseXCookies();
|
||||
for (const method of chain) {
|
||||
this.logger.log(`[${account.id}] Trying via ${method}`);
|
||||
|
||||
if (['cookie', 'browser'].includes(method)) {
|
||||
if (!canUseCookie) {
|
||||
await this.notifyService.sendUrgentMessageToTele('❌ Vui lòng cập nhập cookie để sử dụng ');
|
||||
this.logger.error('Cookie đã hết hạn, vui lòng cập nhập');
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const result = await this.executeTweet(method, account, params.text);
|
||||
attempts.push({method, error: result.error});
|
||||
|
||||
@@ -100,7 +122,7 @@ export class XPosterRouterService {
|
||||
};
|
||||
}
|
||||
|
||||
this.logger.log(`Dăng bài thất bại, thử phương pháp khác`);
|
||||
this.logger.log(`Đăng bài thất bại, thử phương pháp khác`);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user