Created
April 25, 2021 10:58
-
-
Save poeti8/133796200d66049c9bd58e6265a52f68 to your computer and use it in GitHub Desktop.
the-guard-banfiles-plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fix:
Telegraf no longer allows importing from internal paths that aren't explicitly exported.