Compare commits

...

4 Commits

Author SHA1 Message Date
2ca39208d9 Merge branch 'main' of https://gitlab.com/ceda_ei/Quadnite-Bot 2024-10-13 20:28:07 +05:30
7cf9689420 Copy message text for feedback instead of forwarding
Telegram's pseudo-DRM prevents bots from forwarding messages in chats
with "Restrict Saving Content"
2024-10-13 20:26:07 +05:30
1d5c29564f Merge branch 'main' of https://gitlab.com/ceda_ei/Quadnite-Bot 2024-10-04 12:22:22 +05:30
e3a5f1a67b Change rate limit config
Don't send a message and use the chat as key when possible
2024-10-02 22:39:36 +05:30
2 changed files with 8 additions and 7 deletions

9
bot.js
View File

@@ -9,11 +9,10 @@ const { limit } = require("@grammyjs/ratelimiter");
const bot = new Telegraf(BOT_API_KEY);
bot.catch((err) => console.log(err));
bot.use(limit({
// default config: 5 messages per 5 seconds
timeFrame: RATE_TIMEFRAME ?? 5000,
limit: RATE_LIMIT ?? 5,
onLimitExceeded: (ctx, next) => ctx.reply('Too many requests!'),
// default config: 1 message per 1 second
timeFrame: RATE_TIMEFRAME ?? 1000,
limit: RATE_LIMIT ?? 1,
keyGenerator: (ctx) => ctx.chat?.id.toString() ?? ctx.from?.id.toString(),
}))
const data = [

View File

@@ -5,16 +5,18 @@ module.exports = (bot, feedback_id) => (ctx) => {
const from = ctx.message.from;
let contactable = "The developer might contact you regarding your feedback.";
let message;
if (from.username) {
bot.telegram.sendMessage(feedback_id, `Feedback from: @${from.username}`);
message = `Feedback from: @${from.username}`;
} else {
contactable = "The developer might not be able to contact you due to lack of your username.";
message = `Feedback from User ${from.id}`;
}
ctx.forwardMessage(feedback_id);
bot.telegram.sendMessage(feedback_id, `${message} ${ctx.message.text}`).catch(console.log);
return `Thanks for the feedback! ${contactable}`;
} else {