Secured command to prevent spam from regular users.
Main / build-and-push-docker-image (20.x) (pull_request) Successful in 3m1s

This commit is contained in:
2025-10-21 15:09:21 -04:00
parent 10d8f02160
commit d71e736bee
2 changed files with 33 additions and 11 deletions
+10 -1
View File
@@ -15,7 +15,16 @@ feature.hears(
logHandle("bot-info-command"),
async (ctx: Context) => {
// Checks if the context includes a message property.
if (ctx.msg) {
if (ctx.msg && ctx.chat && ctx.msg.from) {
// Doesn't respond to regular users in groups. This is to prevent users spamming the command.
if (ctx.chat.type !== "private") {
const chatMember = await ctx.getChatMember(ctx.msg.from.id);
if (!["creator", "administrator"].includes(chatMember.status)) {
return;
}
}
// Replies to the message.
await ctx.reply(
`I am a bot designed to delete any Twitter/X and Meta links along with corresponding reformatting services\\. I now check embedded links\\!`,