This commit is contained in:
kjy
2026-03-03 21:35:25 +09:00
parent ffdca4f6dd
commit 59a94f08e6
4 changed files with 48 additions and 33 deletions

View File

@@ -2,7 +2,6 @@ node_modules
.git .git
.gitignore .gitignore
*.md *.md
.env
.env.* .env.*
*.log *.log
dist dist

Binary file not shown.

View File

@@ -21,13 +21,21 @@ const telegramService = new TelegramService(
false false
); );
function logWithTime(...args: unknown[]) {
console.log(`[${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`, ...args);
}
function errorWithTime(...args: unknown[]) {
console.error(`[${dayjs().format("YYYY-MM-DD HH:mm:ss")}]`, ...args);
}
async function main() { async function main() {
try { try {
console.time("sendTelegram"); console.time("sendTelegram");
await sendTelegram(); await sendTelegram();
console.timeEnd("sendTelegram"); console.timeEnd("sendTelegram");
} catch (error) { } catch (error) {
console.log(error); errorWithTime(error);
} }
} }
@@ -35,6 +43,7 @@ async function sendTelegram() {
const sendUsers = isTestMode ? testUsers : telegramUsers; const sendUsers = isTestMode ? testUsers : telegramUsers;
for (let telegramUser of sendUsers) { for (let telegramUser of sendUsers) {
try {
const articles = await prisma.realEstateArticle.findMany({ const articles = await prisma.realEstateArticle.findMany({
where: { where: {
isActive: true, isActive: true,
@@ -47,7 +56,7 @@ async function sendTelegram() {
}); });
if (articles.length === 0) { if (articles.length === 0) {
console.log("no articles"); logWithTime("no articles");
continue; continue;
} }
@@ -61,7 +70,14 @@ async function sendTelegram() {
)})` )})`
); );
await unlink(excelFilePath); await unlink(excelFilePath);
console.log("excel file deleted"); logWithTime("excel file deleted");
} catch (error) {
errorWithTime(
`${telegramUser.name}(${telegramUser.chatId}) 처리 실패:`,
error
);
continue;
}
} }
} }

View File

@@ -48,13 +48,13 @@ export const telegramUsers: TelegramUser[] = [
phone: "010-6377-2069", phone: "010-6377-2069",
realtorId: "namyeong00", realtorId: "namyeong00",
}, },
{ // {
site: "부동산써브", // site: "부동산써브",
chatId: 6864925398, // chatId: 6864925398,
name: "박희영", // name: "박희영",
phone: "010-5387-4521", // phone: "010-5387-4521",
realtorId: "namyeong00", // realtorId: "namyeong00",
}, // },
{ {
site: "부동산포스", site: "부동산포스",
chatId: 8155003662, chatId: 8155003662,