Skip to content

Instantly share code, notes, and snippets.

@poeti8
Created April 25, 2021 10:58
Show Gist options
  • Save poeti8/133796200d66049c9bd58e6265a52f68 to your computer and use it in GitHub Desktop.
Save poeti8/133796200d66049c9bd58e6265a52f68 to your computer and use it in GitHub Desktop.
the-guard-banfiles-plugin
'use strict';
const Composer = require('telegraf/composer');
const blacklisted_files = [ 'apk', 'exe', 'scr', 'bat', 'cmd', 'vbs', 'pif' ];
module.exports = Composer.mount('document', (ctx, next) =>
ctx.from.status !== 'admin' &&
blacklisted_files.includes(
ctx.message.document.file_name.split('.').pop())
? Promise.all([
ctx.ban({
admin: ctx.botInfo,
reason: 'Blacklisted file.',
userToBan: ctx.from }),
ctx.deleteMessage() ])
: next());
@C0rn3j
Copy link

C0rn3j commented Sep 18, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment