Reformulation of bot structure
This commit is contained in:
parent
4b9ed6d2c0
commit
2f65126319
15 changed files with 2 additions and 2 deletions
8
commands/bam.js
Normal file
8
commands/bam.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
|
||||
const message = `O usuario foi bamido com sucesso`;
|
||||
|
||||
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
33
commands/chatinfo.js
Normal file
33
commands/chatinfo.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const chatName = msg.chat.title;
|
||||
const chatHandle = msg.chat.username;
|
||||
const isForum = msg.chat.is_forum;
|
||||
let chatNameOutput = "";
|
||||
let chatHandleOutput = "";
|
||||
let isForumOutput = "";
|
||||
|
||||
if (isForum) {
|
||||
isForumOutput = "*This chat is a forum (has topics enabled).*";
|
||||
} else {
|
||||
isForumOutput = "*This chat is not a forum (doesn't have topics enabled).*";
|
||||
}
|
||||
|
||||
if (chatHandle) {
|
||||
chatHandleOutput = `*Chat handle:* @${chatHandle}`;
|
||||
} else {
|
||||
chatHandleOutput = `*Chat handle:* none (private group)`;
|
||||
}
|
||||
|
||||
// if chatName returns undefined, the chat is not a group or channel
|
||||
if (chatName) {
|
||||
chatNameOutput = `*Chat name:* ${chatName}\n${chatHandleOutput}\n*Chat ID:* ${chatId}\n\n${isForumOutput}`;
|
||||
} else {
|
||||
chatNameOutput = "Whoops!\nThis command doesn't work in PM.";
|
||||
}
|
||||
|
||||
const message = chatNameOutput;
|
||||
|
||||
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
21
commands/customize.js
Normal file
21
commands/customize.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
|
||||
const opts = {
|
||||
reply_to_message_id: msg.message_id,
|
||||
reply_markup: {
|
||||
resize_keyboard: true,
|
||||
one_time_keyboard: true,
|
||||
keyboard: [
|
||||
[{text: 'He/Him'}],
|
||||
[{text: 'She/Her'}],
|
||||
[{text: 'They/Them'}],
|
||||
],
|
||||
}
|
||||
};
|
||||
|
||||
const message = "Select your pronouns:";
|
||||
|
||||
bot.sendMessage(chatId, message, opts,{ parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
22
commands/furry.js
Normal file
22
commands/furry.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const userName = msg.from.first_name;
|
||||
let isFurry = "";
|
||||
|
||||
function getRandomInt(max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
}
|
||||
|
||||
const randomValue = getRandomInt(2);
|
||||
|
||||
if (randomValue === 0) {
|
||||
isFurry = `*You (${userName}) are not a furry.*`;
|
||||
} else {
|
||||
isFurry = `*Yes, you (${userName}) are a furry.*`;
|
||||
}
|
||||
|
||||
const message = `${isFurry}`;
|
||||
|
||||
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
22
commands/gay.js
Normal file
22
commands/gay.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const userName = msg.from.first_name;
|
||||
let isGay = "";
|
||||
|
||||
function getRandomInt(max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
}
|
||||
|
||||
const randomValue = getRandomInt(2);
|
||||
|
||||
if (randomValue === 0) {
|
||||
isGay = `*You (${userName}) are not gay.*`;
|
||||
} else {
|
||||
isGay = `*Yes, you (${userName}) are gay.*`;
|
||||
}
|
||||
|
||||
const message = `${isGay}`;
|
||||
|
||||
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
22
commands/help.js
Normal file
22
commands/help.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const lynxFullPhoto = 'https://graph.org/file/a77382dab4d62ba626806.jpg';
|
||||
|
||||
const message = `*Hello! I'm Lynx!*\n\nI'm a simple bot made entirely from scratch in Node.js by Lucas Gabriel (lucmsilva).\n\n` +
|
||||
`I am running on a *GitHub Codespaces* server, and sometimes may I am off, so please refrain from overusing or spamming the bot!\n\n` +
|
||||
`*Some commands to test:*
|
||||
• */chatinfo* - send some information about the group
|
||||
• */customize* - customize your pronouns (WIP)
|
||||
• */furry* - check if you are a furry
|
||||
• */gay* - check if you are gay
|
||||
• */help* - send this message
|
||||
• */privacy* - read the Privacy Policy
|
||||
• */random* - pick a random number between 0-10
|
||||
• */start* - start the bot
|
||||
• */whois* - send some information about yourself\n\n` +
|
||||
`*See my source code in:* [GitHub Repository](https://github.com/lucmsilva651/lynx)\n\n` +
|
||||
`Thanks to all users, testers, contributors, and others. Without you, perhaps this bot wouldn't be possible ❤️`;
|
||||
|
||||
bot.sendPhoto(chatId, lynxFullPhoto, { caption: message, parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
42
commands/privacy.js
Normal file
42
commands/privacy.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
|
||||
const message = `*Privacy Policy for Lynx Telegram Bot (@LynxBR_bot)*\n` +
|
||||
`Before using, you will need to read the privacy policy ` +
|
||||
`to understand where your data goes when using this bot. ` +
|
||||
`If you don't agree with any of these terms, stop using ` +
|
||||
`the bot.\n\n` +
|
||||
`*1. Data Collection and Use*\n` +
|
||||
`All text messages sent to the Lynx bot, along with ` +
|
||||
`their respective identifiers (username and ID), are ` +
|
||||
`collected in a secure environment for the developers. ` +
|
||||
`This data is used solely for the purpose of improving ` +
|
||||
`and debugging the bot and is retained for a period `+
|
||||
`of 60 days before being completely deleted.\n\n` +
|
||||
`*2. Data Sharing*\n` +
|
||||
`Message data, including text and identifiers, is not ` +
|
||||
`shared with any companies or third-party entities.\n\n` +
|
||||
`*3. Legal Compliance*\n` +
|
||||
`In the event of legal action, data will be provided ` +
|
||||
`in accordance with applicable laws and regulations.\n\n` +
|
||||
`*4. User-Generated Content*\n` +
|
||||
`We (the creators, developers, and hosts of the bot) ` +
|
||||
`are not responsible for any content generated by users, ` +
|
||||
`whether it is triggered by our bot or another.\n\n` +
|
||||
`*5. Blocklist System*\n` +
|
||||
`We have implemented a blocklist system via user ID. If ` +
|
||||
`a user generates inappropriate content or misuses the bot, ` +
|
||||
`they will be permanently blocked. If the use of alternative ` +
|
||||
`or secondary accounts by a blocked user is detected, those ` +
|
||||
`accounts will also be blocked.\n\n` +
|
||||
`*6. Source Code*\n` +
|
||||
`If you wish to review the source code, please visit:` +
|
||||
`[https://github.com/lucmsilva651/lynx](https://github.com/lucmsilva651/lynx/).\n\n` +
|
||||
`*7. Terms Modification*\n` +
|
||||
`These terms may be changed or invalidated at any time, with or without prior notice.\n\n` +
|
||||
`*8. Immediate Cancellation of Terms*\n` +
|
||||
`In case of usage block, as mentioned above, the terms will be immediately cancelled for the user.`;
|
||||
|
||||
bot.sendMessage(chatId, message, { parse_mode: 'Markdown', disable_web_page_preview: true })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
};
|
15
commands/random.js
Normal file
15
commands/random.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
|
||||
function getRandomInt(max) {
|
||||
return Math.floor(Math.random() * max);
|
||||
}
|
||||
|
||||
const randomValue = getRandomInt(11);
|
||||
|
||||
const message = `*Generated value:* ${randomValue}`;
|
||||
|
||||
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
||||
|
12
commands/start.js
Normal file
12
commands/start.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const lynxProfilePhoto = 'https://graph.org/file/10452df450f13ffb968c5.jpg';
|
||||
|
||||
const message = `*Hello! I am Lynx!*\nI was made with love by Lucas Gabriel (lucmsilva)!\n\n` +
|
||||
`*Before using, you will need to read the privacy policy (/privacy) ` +
|
||||
`to understand where your data goes when using this bot.*\n\n` +
|
||||
`Also, you can use /help to show the bot commands!`;
|
||||
|
||||
bot.sendPhoto(chatId, lynxProfilePhoto, { caption: message, parse_mode: 'Markdown' } )
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
54
commands/stats.js
Normal file
54
commands/stats.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
const os = require('os');
|
||||
|
||||
module.exports = function (bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const botAdmin = process.env.TGBOT_ADMINS;
|
||||
|
||||
function formatUptime(uptime) {
|
||||
const hours = Math.floor(uptime / 3600);
|
||||
const minutes = Math.floor((uptime % 3600) / 60);
|
||||
const seconds = Math.floor(uptime % 60);
|
||||
return `${hours}h ${minutes}m ${seconds}s`;
|
||||
}
|
||||
|
||||
function getSystemInfo() {
|
||||
const platform = os.platform();
|
||||
const release = os.release();
|
||||
const arch = os.arch();
|
||||
const cpuModel = os.cpus()[0].model;
|
||||
const cpuCores = os.cpus().length;
|
||||
const totalMemory = (os.totalmem() / (1024 ** 3)).toFixed(2) + ' GB';
|
||||
const freeMemory = (os.freemem() / (1024 ** 3)).toFixed(2) + ' GB';
|
||||
const loadAverage = os.loadavg().map(avg => avg.toFixed(2)).join(', ');
|
||||
const uptime = formatUptime(os.uptime());
|
||||
const nodeVersion = process.version;
|
||||
const homeDir = os.homedir();
|
||||
const hostName = os.hostname();
|
||||
const tempDir = os.tmpdir();
|
||||
const userInfo = os.userInfo();
|
||||
|
||||
return `*Server Stats*\n\n` +
|
||||
`*OS:* \`${platform} ${release}\`\n` +
|
||||
`*Arch:* \`${arch}\`\n` +
|
||||
`*Node.js Version:* \`${nodeVersion}\`\n` +
|
||||
`*CPU:* \`${cpuModel}\`\n` +
|
||||
`*CPU Cores:* \`${cpuCores} cores\`\n` +
|
||||
`*RAM:* \`${freeMemory} / ${totalMemory}\`\n` +
|
||||
`*Load Average:* \`${loadAverage}\`\n` +
|
||||
`*Uptime:* \`${uptime}\`\n\n` +
|
||||
`*Username*: \`${userInfo.username}\`\n` +
|
||||
`*Hostname:* \`${hostName}\`\n` +
|
||||
`*Home Directory:* \`${homeDir}\`\n` +
|
||||
`*Temp. Directory:* \`${tempDir}\``;
|
||||
}
|
||||
|
||||
const message = getSystemInfo();
|
||||
|
||||
const isAdmin = botAdmin.includes(msg.from.id.toString());
|
||||
if (isAdmin) {
|
||||
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
28
commands/whois.js
Normal file
28
commands/whois.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
module.exports = function(bot, msg) {
|
||||
const chatId = msg.chat.id;
|
||||
const userName = msg.from.first_name;
|
||||
const userId = msg.from.id;
|
||||
const userHandle = msg.from.username;
|
||||
const isBot = msg.from.is_bot;
|
||||
const userPremium = msg.from.is_premium;
|
||||
const userLang = msg.from.language_code;
|
||||
let haveUsername = "";
|
||||
let userPremiumOutput = "";
|
||||
|
||||
if (userPremium) {
|
||||
userPremiumOutput = "*You have a Telegram Premium subscription.*";
|
||||
} else {
|
||||
userPremiumOutput = "*You don't have a Telegram Premium subscription.*";
|
||||
}
|
||||
|
||||
if (userHandle) {
|
||||
haveUsername = `*Your username is:* @${userHandle}`;
|
||||
} else {
|
||||
haveUsername = "*Your username is:* none";
|
||||
}
|
||||
|
||||
const message = `*Your name is:* ${userName}\n${haveUsername}\n*Your ID is:* ${userId}\n*You are a bot:* ${isBot}\n*Your language:* ${userLang}\n\n${userPremiumOutput}`;
|
||||
|
||||
bot.sendMessage(chatId, message, { parse_mode: 'Markdown' })
|
||||
.catch(error => console.error('WARN: Message cannot be sent: ', error));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue