mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 21:00:03 +00:00
Tryng to implement blocklist
This commit is contained in:
parent
755ae2c8f8
commit
4770d9a65d
11
src/commands/.start.js
Normal file
11
src/commands/.start.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const userName = msg.from.first_name;
|
||||
const userId = msg.from.id;
|
||||
|
||||
const message = `Hello! I am Lynx!\nI was made with love by Lucas Gabriel (lucmsilva)!\n\nSee /help for the bot commands!`
|
||||
|
||||
bot.sendMessage(chatId, message)
|
||||
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||
console.log(`INFO: /start executed by ${userName}, ${userId}`)
|
||||
}
|
@ -1,11 +1,27 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const userName = msg.from.first_name;
|
||||
const userId = msg.from.id;
|
||||
const userId = msg.from.id.toString();
|
||||
|
||||
const blocklistPath = path.join(__dirname, '../../blocklist.txt');
|
||||
let blocklist = [];
|
||||
try {
|
||||
blocklist = fs.readFileSync(blocklistPath, 'utf8').split('\n').map(id => id.trim());
|
||||
} catch (err) {
|
||||
console.error(`Erro ao carregar a blocklist: ${err}`);
|
||||
}
|
||||
|
||||
if (blocklist.includes(userId)) {
|
||||
bot.sendMessage(chatId, "You are blocked from use this bot.\nDon't even try using a alternative account, as you will be blocked too.");
|
||||
return;
|
||||
}
|
||||
|
||||
const userName = msg.from.first_name;
|
||||
const message = `Hello! I am Lynx!\nI was made with love by Lucas Gabriel (lucmsilva)!\n\nSee /help for the bot commands!`;
|
||||
|
||||
const message = `Hello! I am Lynx!\nI was made with love by Lucas Gabriel (lucmsilva)!\n\nSee /help for the bot commands!`
|
||||
|
||||
bot.sendMessage(chatId, message)
|
||||
.catch(error => console.error('ERROR: Message cannot be sent:', error));
|
||||
console.log(`INFO: /start executed by ${userName}, ${userId}`)
|
||||
}
|
||||
console.log(`INFO: /start executed by ${userName}, ${userId}`);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user