mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-29 05:07:49 +00:00
added styling format for messages
This commit is contained in:
parent
5cb22a6b5c
commit
1036ad5f88
@ -25,11 +25,12 @@ const adminHandler = async ({ message, reply }) => {
|
|||||||
: message.from;
|
: message.from;
|
||||||
|
|
||||||
if (await isBanned(userToAdmin)) {
|
if (await isBanned(userToAdmin)) {
|
||||||
return reply('Can\'t admin banned user');
|
return reply('ℹ️ <b>Can\'t admin banned user.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await isAdmin(userToAdmin)) {
|
if (await isAdmin(userToAdmin)) {
|
||||||
return reply('Already admin');
|
return reply(`⭐️ ${link(userToAdmin)} <b>is already admin.</b>.`,
|
||||||
|
replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await getWarns(userToAdmin)) {
|
if (await getWarns(userToAdmin)) {
|
||||||
@ -46,7 +47,7 @@ const adminHandler = async ({ message, reply }) => {
|
|||||||
logError(process.env.DEBUG)(err);
|
logError(process.env.DEBUG)(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reply(`${link(userToAdmin)} is now <b>admin</b>.`, replyOptions);
|
return reply(`⭐️ ${link(userToAdmin)} <b>is now admin.</b>.`, replyOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = adminHandler;
|
module.exports = adminHandler;
|
||||||
|
@ -22,21 +22,22 @@ const banHandler = async ({ chat, message, reply, telegram }) => {
|
|||||||
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
||||||
|
|
||||||
if (reason.length === 0) {
|
if (reason.length === 0) {
|
||||||
return reply('Need a reason to ban');
|
return reply('ℹ️ <b>Need a reason to ban.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!message.reply_to_message) {
|
if (!message.reply_to_message) {
|
||||||
return reply('Reply to a message');
|
return reply('ℹ️ <b>Reply to a message.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
bot.telegram.deleteMessage(chat.id, message.reply_to_message.message_id);
|
bot.telegram.deleteMessage(chat.id, message.reply_to_message.message_id);
|
||||||
|
|
||||||
if (await isAdmin(userToBan)) {
|
if (await isAdmin(userToBan)) {
|
||||||
return reply('Can\'t ban other admin');
|
return reply('ℹ️ <b>Can\'t ban other admins.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await isBanned(userToBan)) {
|
if (await isBanned(userToBan)) {
|
||||||
return reply('User is already banned.');
|
return reply(`🚫 ${link(userToBan)} <b>is already banned.</b>`,
|
||||||
|
replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -56,7 +57,7 @@ const banHandler = async ({ chat, message, reply, telegram }) => {
|
|||||||
logError(process.env.DEBUG)(err);
|
logError(process.env.DEBUG)(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reply(`${link(userToBan)} has been <b>banned</b>.\n\n` +
|
return reply(`🚫 ${link(userToBan)} <b>got banned</b>.\n\n` +
|
||||||
`Reason: ${reason}`, replyOptions);
|
`Reason: ${reason}`, replyOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@ const getWarnsHandler = async ({ message, reply }) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!message.reply_to_message) {
|
if (!message.reply_to_message) {
|
||||||
return reply('Reply to a message');
|
return reply('ℹ️ <b>Reply to a message.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const theUser = message.reply_to_message.from;
|
const theUser = message.reply_to_message.from;
|
||||||
return reply('Warns for ' + link(theUser) + ':\n\n' +
|
return reply(`⚠️ <b>Warns for</b> ${link(theUser)}:\n\n` +
|
||||||
(await Warn.getWarns(theUser))
|
(await Warn.getWarns(theUser))
|
||||||
.map(x => ++i + '. ' + x)
|
.map(warn => ++i + '. ' + warn)
|
||||||
.join('\n\n'), replyOptions);
|
.join('\n\n'), replyOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ const nowarnsHandler = async ({ message, reply }) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!message.reply_to_message) {
|
if (!message.reply_to_message) {
|
||||||
return reply('Reply to a message');
|
return reply('ℹ️ <b>Reply to a message.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageToUnwarn = message.reply_to_message;
|
const messageToUnwarn = message.reply_to_message;
|
||||||
@ -29,7 +29,8 @@ const nowarnsHandler = async ({ message, reply }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return reply(
|
return reply(
|
||||||
`${link(userToUnwarn)} was pardoned for all of their warnings.`,
|
`♻️ ${link(userToUnwarn)} <b>was pardoned for ` +
|
||||||
|
'all of their warnings.</b>',
|
||||||
replyOptions);
|
replyOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -20,13 +20,14 @@ const unAdminHandler = async ({ message, reply }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!message.reply_to_message) {
|
if (!message.reply_to_message) {
|
||||||
return reply('Reply to a message');
|
return reply('ℹ️ <b>Reply to a message.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userToUnadmin = message.reply_to_message.from;
|
const userToUnadmin = message.reply_to_message.from;
|
||||||
|
|
||||||
if (!await isAdmin(userToUnadmin)) {
|
if (!await isAdmin(userToUnadmin)) {
|
||||||
return reply(`${link(userToUnadmin)} is not admin.`, replyOptions);
|
return reply(`ℹ️ ${link(userToUnadmin)} <b>is not admin.</b>`,
|
||||||
|
replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -35,7 +36,8 @@ const unAdminHandler = async ({ message, reply }) => {
|
|||||||
logError(process.env.DEBUG)(err);
|
logError(process.env.DEBUG)(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reply(`${link(userToUnadmin)} is no longer admin.`, replyOptions);
|
return reply(`❗️ ${link(userToUnadmin)} <b>is no longer admin.</b>`,
|
||||||
|
replyOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = unAdminHandler;
|
module.exports = unAdminHandler;
|
||||||
|
@ -18,13 +18,13 @@ const unbanHandler = async ({ message, reply, telegram }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!message.reply_to_message) {
|
if (!message.reply_to_message) {
|
||||||
return reply('Reply to a message');
|
return reply('ℹ️ <b>Reply to a message.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const userToUnban = message.reply_to_message.from;
|
const userToUnban = message.reply_to_message.from;
|
||||||
|
|
||||||
if (!await isBanned(userToUnban)) {
|
if (!await isBanned(userToUnban)) {
|
||||||
return reply('User is not banned.');
|
return reply('ℹ️ <b>User is not banned.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const groups = await listGroups();
|
const groups = await listGroups();
|
||||||
@ -44,7 +44,8 @@ const unbanHandler = async ({ message, reply, telegram }) => {
|
|||||||
logError(process.env.DEBUG)(err);
|
logError(process.env.DEBUG)(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reply(`${link(userToUnban)} has been unbanned.`, replyOptions);
|
return reply(`♻️ ${link(userToUnban)} <b>is unbanned.</b>`,
|
||||||
|
replyOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = unbanHandler;
|
module.exports = unbanHandler;
|
||||||
|
@ -15,7 +15,7 @@ const unwarnHandler = async ({ message, reply }) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!message.reply_to_message) {
|
if (!message.reply_to_message) {
|
||||||
return reply('Reply to a message');
|
return reply('ℹ️ <b>Reply to a message.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageToUnwarn = message.reply_to_message;
|
const messageToUnwarn = message.reply_to_message;
|
||||||
@ -25,7 +25,7 @@ const unwarnHandler = async ({ message, reply }) => {
|
|||||||
const warn = await Warn.unwarn(userToUnwarn);
|
const warn = await Warn.unwarn(userToUnwarn);
|
||||||
|
|
||||||
return reply(
|
return reply(
|
||||||
`${link(userToUnwarn)} was pardoned for: ${warn}\n` +
|
`❎ ${link(userToUnwarn)} <b>was pardoned for:</b>\n\n${warn}` +
|
||||||
`(${allWarns.length}/3)`,
|
`(${allWarns.length}/3)`,
|
||||||
replyOptions);
|
replyOptions);
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,7 @@ const warnHandler = async ({ message, chat, reply }) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!message.reply_to_message) {
|
if (!message.reply_to_message) {
|
||||||
return reply('Reply to a message');
|
return reply('ℹ️ <b>Reply to a message.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageToWarn = message.reply_to_message;
|
const messageToWarn = message.reply_to_message;
|
||||||
@ -30,11 +30,11 @@ const warnHandler = async ({ message, chat, reply }) => {
|
|||||||
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
||||||
|
|
||||||
if (reason.length === 0) {
|
if (reason.length === 0) {
|
||||||
return reply('Need a reason to warn');
|
return reply('ℹ️ <b>Need a reason to warn.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await isAdmin(userToWarn)) {
|
if (await isAdmin(userToWarn)) {
|
||||||
return reply('Can\'t warn other admin');
|
return reply('ℹ️ <b>Can\'t warn other admins.</b>', replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
const warnCount = await warn(userToWarn, reason);
|
const warnCount = await warn(userToWarn, reason);
|
||||||
@ -45,14 +45,14 @@ const warnHandler = async ({ message, chat, reply }) => {
|
|||||||
|
|
||||||
if (warnCount < numberOfWarnsToBan) {
|
if (warnCount < numberOfWarnsToBan) {
|
||||||
promises.push(reply(
|
promises.push(reply(
|
||||||
`${link(userToWarn)} <b>got warned!</b> (${warnCount}/3)\n\n` +
|
`⚠️ ${link(userToWarn)} <b>got warned!</b> (${warnCount}/3)\n\n` +
|
||||||
`Reason: ${reason}`,
|
`Reason: ${reason}`,
|
||||||
replyOptions));
|
replyOptions));
|
||||||
} else {
|
} else {
|
||||||
promises.push(bot.telegram.kickChatMember(chat.id, userToWarn.id));
|
promises.push(bot.telegram.kickChatMember(chat.id, userToWarn.id));
|
||||||
promises.push(ban(userToWarn, 'Reached max number of warnings'));
|
promises.push(ban(userToWarn, 'Reached max number of warnings'));
|
||||||
promises.push(reply(
|
promises.push(reply(
|
||||||
`${link(userToWarn)} <b>banned</b>! (${warnCount}/3)\n` +
|
`🚫 ${link(userToWarn)} <b>got banned!</b> (${warnCount}/3)\n\n` +
|
||||||
'Reason: Reached max number of warnings',
|
'Reason: Reached max number of warnings',
|
||||||
replyOptions));
|
replyOptions));
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// Bot
|
||||||
|
const { replyOptions } = require('../../bot/options');
|
||||||
|
|
||||||
const { addGroup } = require('../../stores/groups');
|
const { addGroup } = require('../../stores/groups');
|
||||||
const { masterID } = require('../../config.json');
|
const { masterID } = require('../../config.json');
|
||||||
|
|
||||||
@ -10,7 +13,8 @@ const addedToGroupHandler = (ctx, next) => {
|
|||||||
user.username === ctx.me);
|
user.username === ctx.me);
|
||||||
if (wasAdded && ctx.from.id === masterID) {
|
if (wasAdded && ctx.from.id === masterID) {
|
||||||
addGroup(ctx.chat);
|
addGroup(ctx.chat);
|
||||||
ctx.reply('Ok, I\'ll help you manage this group from now.');
|
ctx.reply('🛠 <b>Ok, I\'ll help you manage this group from now.</b>',
|
||||||
|
replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// Bot
|
||||||
|
const { replyOptions } = require('../../bot/options');
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
const { isAdmin } = require('../../stores/admin');
|
const { isAdmin } = require('../../stores/admin');
|
||||||
|
|
||||||
@ -24,7 +27,8 @@ const antibotHandler = async (ctx, next) => {
|
|||||||
ctx.telegram.kickChatMember(ctx.chat.id, bot.id);
|
ctx.telegram.kickChatMember(ctx.chat.id, bot.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.reply(`Kicked bot(s): ${bots.map(link).join(', ')}`);
|
ctx.reply(`🚫 <b>Kicked bot(s):</b> ${bots.map(link).join(', ')}`,
|
||||||
|
replyOptions);
|
||||||
|
|
||||||
return next();
|
return next();
|
||||||
};
|
};
|
||||||
|
@ -37,7 +37,7 @@ const middlewareHandler = async ({ chat, from, message, reply }, next) => {
|
|||||||
if (banned) {
|
if (banned) {
|
||||||
return bot.telegram.kickChatMember(chat.id, from.id)
|
return bot.telegram.kickChatMember(chat.id, from.id)
|
||||||
.then(() => reply(
|
.then(() => reply(
|
||||||
`${link(from)} <b>banned</b>!\n` +
|
`🚫 ${link(from)} <b>is banned</b>!\n\n` +
|
||||||
`Reason: ${banned}`,
|
`Reason: ${banned}`,
|
||||||
replyOptions))
|
replyOptions))
|
||||||
.catch(logError(process.env.DEBUG))
|
.catch(logError(process.env.DEBUG))
|
||||||
|
@ -36,24 +36,23 @@ const removeLinks = async ({ message, chat, reply }, next) => {
|
|||||||
if (await isAdmin(userToWarn)) {
|
if (await isAdmin(userToWarn)) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
const reason = 'Sent a message which was forwarded ' +
|
const reason = 'Channel forward/link';
|
||||||
'from other channels or included their link';
|
|
||||||
const warnCount = await warn(userToWarn, reason);
|
const warnCount = await warn(userToWarn, reason);
|
||||||
const promises = [
|
const promises = [
|
||||||
bot.telegram.deleteMessage(chat.id, message.message_id)
|
bot.telegram.deleteMessage(chat.id, message.message_id)
|
||||||
];
|
];
|
||||||
if (warnCount < numberOfWarnsToBan) {
|
if (warnCount < numberOfWarnsToBan) {
|
||||||
promises.push(reply(
|
promises.push(reply(
|
||||||
`${link(userToWarn)} warned! (${warnCount}/3)\n` +
|
`⚠️ ${link(userToWarn)} <b>got warned!</b> (${warnCount}/3)` +
|
||||||
`Reason: ${reason}`,
|
`\n\nReason: ${reason}`,
|
||||||
replyOptions));
|
replyOptions));
|
||||||
} else {
|
} else {
|
||||||
promises.push(bot.telegram.kickChatMember(chat.id, userToWarn.id));
|
promises.push(bot.telegram.kickChatMember(chat.id, userToWarn.id));
|
||||||
promises.push(ban(userToWarn,
|
promises.push(ban(userToWarn,
|
||||||
'Reached max number of warnings'));
|
'Reached max number of warnings'));
|
||||||
promises.push(reply(
|
promises.push(reply(
|
||||||
`${link(userToWarn)} <b>banned</b>! (${warnCount}/3)\n` +
|
`🚫 ${link(userToWarn)} <b>got banned</b>! (${warnCount}/3)` +
|
||||||
'Reason: Reached max number of warnings',
|
'\n\nReason: Reached max number of warnings',
|
||||||
replyOptions));
|
replyOptions));
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user