2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-09-01 14:45:27 +00:00

added styling format for messages

This commit is contained in:
Pouria Ezzati
2017-09-24 14:28:18 +03:30
parent 5cb22a6b5c
commit 1036ad5f88
12 changed files with 48 additions and 35 deletions

View File

@@ -25,11 +25,12 @@ const adminHandler = async ({ message, reply }) => {
: message.from;
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)) {
return reply('Already admin');
return reply(`⭐️ ${link(userToAdmin)} <b>is already admin.</b>.`,
replyOptions);
}
if (await getWarns(userToAdmin)) {
@@ -46,7 +47,7 @@ const adminHandler = async ({ message, reply }) => {
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;

View File

@@ -22,21 +22,22 @@ const banHandler = async ({ chat, message, reply, telegram }) => {
const reason = message.text.split(' ').slice(1).join(' ').trim();
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) {
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);
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)) {
return reply('User is already banned.');
return reply(`🚫 ${link(userToBan)} <b>is already banned.</b>`,
replyOptions);
}
try {
@@ -56,7 +57,7 @@ const banHandler = async ({ chat, message, reply, telegram }) => {
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);
};

View File

@@ -15,13 +15,13 @@ const getWarnsHandler = async ({ message, reply }) => {
return null;
}
if (!message.reply_to_message) {
return reply('Reply to a message');
return reply(' <b>Reply to a message.</b>', replyOptions);
}
let i = 0;
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))
.map(x => ++i + '. ' + x)
.map(warn => ++i + '. ' + warn)
.join('\n\n'), replyOptions);
};

View File

@@ -16,7 +16,7 @@ const nowarnsHandler = async ({ message, reply }) => {
return null;
}
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;
@@ -29,7 +29,8 @@ const nowarnsHandler = async ({ message, reply }) => {
}
return reply(
`${link(userToUnwarn)} was pardoned for all of their warnings.`,
`♻️ ${link(userToUnwarn)} <b>was pardoned for ` +
'all of their warnings.</b>',
replyOptions);
};

View File

@@ -20,13 +20,14 @@ const unAdminHandler = async ({ message, reply }) => {
}
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;
if (!await isAdmin(userToUnadmin)) {
return reply(`${link(userToUnadmin)} is not admin.`, replyOptions);
return reply(` ${link(userToUnadmin)} <b>is not admin.</b>`,
replyOptions);
}
try {
@@ -35,7 +36,8 @@ const unAdminHandler = async ({ message, reply }) => {
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;

View File

@@ -18,13 +18,13 @@ const unbanHandler = async ({ message, reply, telegram }) => {
}
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;
if (!await isBanned(userToUnban)) {
return reply('User is not banned.');
return reply(' <b>User is not banned.</b>', replyOptions);
}
const groups = await listGroups();
@@ -44,7 +44,8 @@ const unbanHandler = async ({ message, reply, telegram }) => {
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;

View File

@@ -15,7 +15,7 @@ const unwarnHandler = async ({ message, reply }) => {
return null;
}
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;
@@ -25,7 +25,7 @@ const unwarnHandler = async ({ message, reply }) => {
const warn = await Warn.unwarn(userToUnwarn);
return reply(
`${link(userToUnwarn)} was pardoned for: ${warn}\n` +
`${link(userToUnwarn)} <b>was pardoned for:</b>\n\n${warn}` +
`(${allWarns.length}/3)`,
replyOptions);
};

View File

@@ -22,7 +22,7 @@ const warnHandler = async ({ message, chat, reply }) => {
return null;
}
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;
@@ -30,11 +30,11 @@ const warnHandler = async ({ message, chat, reply }) => {
const reason = message.text.split(' ').slice(1).join(' ').trim();
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)) {
return reply('Can\'t warn other admin');
return reply(' <b>Can\'t warn other admins.</b>', replyOptions);
}
const warnCount = await warn(userToWarn, reason);
@@ -45,14 +45,14 @@ const warnHandler = async ({ message, chat, reply }) => {
if (warnCount < numberOfWarnsToBan) {
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}`,
replyOptions));
} else {
promises.push(bot.telegram.kickChatMember(chat.id, userToWarn.id));
promises.push(ban(userToWarn, 'Reached max number of warnings'));
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',
replyOptions));
}