Skip to content

Commit eb76e2a

Browse files
committed
Added configurable inline keyboard in warn messages
1 parent fc15270 commit eb76e2a

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

config.example.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55

66
"deleteCommands": "own", // which messages with commands should be deleted?
77
// valid options: "all", "own" (leave commands meant for other bots, this is the default), "none".
8-
8+
99
"numberOfWarnsToBan": 3, // Number of warns that will get someone banned.
1010
"groupsInlineKeyboard": [], // [[inlineButton]] -> inline keyboard to be added to reply to /groups
11-
11+
"warnInlineKeyboard": [], // [[inlineButton]] -> inline keyboard to be added to warn message
12+
1213
// [String] -> list of channels or groups links/usernames that you want to be excluded from warnings
1314
// use "*" to disable this feature.
1415
"excludedChannels": [],

handlers/commands/warn.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ const { link, scheduleDeletion } = require('../../utils/tg');
55
const { logError } = require('../../utils/log');
66

77
// Config
8-
const { numberOfWarnsToBan } = require('../../config.json');
8+
const {
9+
numberOfWarnsToBan,
10+
warnsInlineKeyboard,
11+
} = require('../../config.json');
12+
const reply_markup = { inline_keyboard: warnsInlineKeyboard };
913

1014
// Bot
1115
const bot = require('../../bot');
@@ -61,7 +65,7 @@ const warnHandler = async ({ message, chat, reply, me, state }) => {
6165
await reply(
6266
`⚠️ ${link(user)} <b>warned</b> ${link(userToWarn)} <b>for:</b>` +
6367
`\n\n${reason} (${warnCount.length}/${numberOfWarnsToBan})`,
64-
replyOptions
68+
{ parse_mode: 'HTML', reply_markup }
6569
);
6670
} catch (e) {
6771
// we don't expect an error

handlers/messages/removeLinks.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ const { logError } = require('../../utils/log');
88
const {
99
excludedChannels,
1010
excludedGroups,
11-
numberOfWarnsToBan
11+
numberOfWarnsToBan,
12+
warnsInlineKeyboard,
1213
} = require('../../config.json');
14+
const reply_markup = { inline_keyboard: warnsInlineKeyboard };
15+
1316

1417
// Bot
1518
const bot = require('../../bot');
@@ -120,7 +123,7 @@ const removeLinks = async ({ message, chat, reply, state }, next) => {
120123
promises.push(reply(
121124
`⚠️ ${link(user)} <b>got warned!</b> (${warnCount.length}/3)` +
122125
`\n\nReason: ${reason}`,
123-
replyOptions
126+
{ parse_mode: 'HTML', reply_markup }
124127
));
125128
} else {
126129
promises.push(bot.telegram.kickChatMember(chat.id, user.id));

0 commit comments

Comments
 (0)