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