D
This commit is contained in:
@@ -8,12 +8,13 @@ export class NotifyService {
|
||||
|
||||
const BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN!;
|
||||
const CHAT_ID = process.env.TELEGRAM_CHAT_ID!;
|
||||
const X_USERNAME = process.env.X_USERNAME!;
|
||||
|
||||
await axios.post(
|
||||
`https://api.telegram.org/bot${BOT_TOKEN}/sendMessage`,
|
||||
{
|
||||
chat_id: CHAT_ID,
|
||||
text: message,
|
||||
text: `F:${X_USERNAME}==>${message}`,
|
||||
parse_mode: 'HTML'
|
||||
}
|
||||
);
|
||||
|
||||
@@ -214,6 +214,14 @@ export class XBrowserService implements OnModuleInit, OnModuleDestroy {
|
||||
needsRelogin: true,
|
||||
};
|
||||
}
|
||||
|
||||
const isLoggedIn = await page
|
||||
.locator('[data-testid="SideNav_AccountSwitcher_Button"], [data-testid="AppTabBar_Home_Link"]')
|
||||
.first()
|
||||
.isVisible()
|
||||
.catch(() => false);
|
||||
console.log(`postTweet: ${isLoggedIn ? 'LOGGED IN' : 'LOGGED OUT'}`);
|
||||
|
||||
await page.mouse.wheel(200, rand(300, 800));
|
||||
await page.waitForTimeout(rand(2000, 5000));
|
||||
await page.evaluate(() => window.scrollTo({top: 0, behavior: 'smooth'}));
|
||||
@@ -286,6 +294,14 @@ export class XBrowserService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
await page.waitForTimeout(rand(2000, 4000));
|
||||
|
||||
const isLoggedIn = await page
|
||||
.locator('[data-testid="SideNav_AccountSwitcher_Button"], [data-testid="AppTabBar_Home_Link"]')
|
||||
.first()
|
||||
.isVisible()
|
||||
.catch(() => false);
|
||||
console.log(`postQuote: ${isLoggedIn ? 'LOGGED IN' : 'LOGGED OUT'}`);
|
||||
|
||||
|
||||
// ===== CHECK LOGIN =====
|
||||
if (await page.locator('input[name="text"]').count()) {
|
||||
console.log('❌ Cookie die → bị redirect login');
|
||||
@@ -433,6 +449,13 @@ export class XBrowserService implements OnModuleInit, OnModuleDestroy {
|
||||
console.log(`đợi UI ổn...`)
|
||||
await page.waitForSelector('article', {timeout: 7000});
|
||||
|
||||
const isLoggedIn = await page
|
||||
.locator('[data-testid="SideNav_AccountSwitcher_Button"], [data-testid="AppTabBar_Home_Link"]')
|
||||
.first()
|
||||
.isVisible()
|
||||
.catch(() => false);
|
||||
console.log(`postReply: ${isLoggedIn ? 'LOGGED IN' : 'LOGGED OUT'}`);
|
||||
|
||||
// scroll nhẹ
|
||||
console.log(`scroll nhẹ ...`)
|
||||
await page.mouse.wheel(0, 300);
|
||||
|
||||
@@ -61,6 +61,7 @@ export class XPosterRouterService {
|
||||
}
|
||||
|
||||
async verifyCookie(): Promise<any> {
|
||||
console.debug('==> Verify Cookie');
|
||||
// const isAlive = await this.cookieSvc.verifyCookie();
|
||||
const isAlive = await this.browserSvc.verifyCookie();
|
||||
if (!isAlive) {
|
||||
@@ -68,6 +69,7 @@ export class XPosterRouterService {
|
||||
await this.notifyService.sendUrgentMessageToTele('Cookie đã hết hạn vui lòng cập nhập để sử dụng.')
|
||||
}
|
||||
await this.xCacheService.setStateXCookiesIsSillALive();
|
||||
await this.notifyService.sendMessageToTele('Verify cookie pass')
|
||||
}
|
||||
|
||||
async canUseXCookies(): Promise<boolean> {
|
||||
|
||||
Reference in New Issue
Block a user