This commit is contained in:
NAME
2026-05-12 03:43:19 +00:00
parent 34a678b3c3
commit d9766dc7f0
3 changed files with 39 additions and 9 deletions
+7 -1
View File
@@ -197,7 +197,13 @@ export class XBrowserService implements OnModuleInit, OnModuleDestroy {
const textarea = page.locator('div[data-testid="tweetTextarea_0"]');
await page.waitForTimeout(2000 + (Math.random() + Math.random()) * 3000);
await textarea.fill(text);
// nhập content (fallback nếu type fail)
try {
await textarea.fill(''); // clear
await textarea.type(text, {delay: 50 + Math.random() * 200});
} catch {
await textarea.fill(text);
}
console.log(' Nhập tweet xong ...');
await page.waitForTimeout(2000 + (Math.random() + Math.random()) * 3000);
await page.waitForTimeout(5000);
+6 -3
View File
@@ -21,7 +21,7 @@ export enum XStrategy {
BROWSER_ONLY = 'browser_only',
AUTO = 'auto', // dựa vào health account
BROWSER_API = 'browser_api',
BROWSER_COOKIE = 'browser_cookie'// khi cần chống bot nặng
BROWSER_COOKIE = 'browser_cookie'
}
export interface UnifiedAccount {
@@ -196,7 +196,10 @@ export class XPosterRouterService {
tweetUrl: params.tweetUrl,
tweetId: params.tweetId,
});
attempts.push({method, error: result.error});
attempts.push({
method,
error: method + ':' + result.error
});
if (result.success) {
return {
@@ -260,7 +263,7 @@ export class XPosterRouterService {
text: string,
): Promise<{ success: boolean; tweetId?: string; error?: string }> {
try {
if (method === 'api' && account.api) {
if (method === 'api' && account.api && account.api?.appKey) {
const {data: r} = await this.apiSvc.postSimpleTweet(text);
return {
tweetId: r.id,