Compare commits
4 Commits
7ea30c8c71
...
main
Author | SHA1 | Date | |
---|---|---|---|
2ca39208d9 | |||
7cf9689420 | |||
1d5c29564f | |||
e3a5f1a67b |
9
bot.js
9
bot.js
@@ -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 = [
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user