udate
This commit is contained in:
@@ -117,8 +117,14 @@ export class SqsPosterWorker {
|
||||
console.log(`==> doPostTweet publish to X`);
|
||||
|
||||
// @ts-ignore
|
||||
await this.xRouterService.postTweet({text, strategy});
|
||||
// await this.notifyService.sendMessageToTele(`Post to X success!`);
|
||||
const r = await this.xRouterService.postTweet({text, strategy});
|
||||
if (r.success) {
|
||||
await this.notifyService.sendMessageToTele(`Post to X success!`);
|
||||
} else {
|
||||
const mergerError = r.attempts.map(m => m.error).join(", ");
|
||||
this.logger.error(mergerError);
|
||||
await this.notifyService.sendMessageToTele(`==>.doPostTweet X got error ${mergerError}`)
|
||||
}
|
||||
sendSuccess = true;
|
||||
}
|
||||
|
||||
@@ -141,7 +147,13 @@ export class SqsPosterWorker {
|
||||
console.log('doReplyTweet');
|
||||
// @ts-ignore
|
||||
const r = await this.xRouterService.postReply({text, tweetUrl, tweetId, strategy});
|
||||
if (r.success) {
|
||||
await this.notifyService.sendMessageToTele(`Worker->reply message success`)
|
||||
} else {
|
||||
const mergerError = r.attempts.map(m => m.error).join(", ");
|
||||
this.logger.error(mergerError);
|
||||
await this.notifyService.sendMessageToTele(`==> doReplyTweet error ${mergerError}`)
|
||||
}
|
||||
return r
|
||||
} catch (e) {
|
||||
this.logger.error(e);
|
||||
@@ -163,11 +175,20 @@ export class SqsPosterWorker {
|
||||
console.log('doQuoteTweet');
|
||||
// @ts-ignore
|
||||
const r = await this.xRouterService.postQuote({text, tweetUrl, tweetId, strategy});
|
||||
if (r.success) {
|
||||
await this.notifyService.sendMessageToTele(`✅ Quote message success`)
|
||||
} else {
|
||||
|
||||
const mergerError = r.attempts.map(m => m.error).join(", ");
|
||||
|
||||
this.logger.error(mergerError);
|
||||
await this.notifyService.sendMessageToTele(`==> doQuoteTweet error ${mergerError}`)
|
||||
|
||||
}
|
||||
return r
|
||||
} catch (e) {
|
||||
this.logger.error(e);
|
||||
await this.notifyService.sendMessageToTele(`==> doQuoteTweet error:${e.message}`)
|
||||
await this.notifyService.sendMessageToTele(`==> doQuoteTweet catch error:${e.message}`)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
// 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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user