KOW-3 Fix TMA validation
This commit is contained in:
parent
72ebc0a4ff
commit
d711e64cd9
1 changed files with 21 additions and 17 deletions
|
@ -61,23 +61,27 @@ export default (bot: Telegraf<Context>) => {
|
||||||
...({ reply_to_message_id })
|
...({ reply_to_message_id })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const numberRegex = /^\d+$/;
|
||||||
const result = await downloadModule(moduleId);
|
const isNumber = numberRegex.test(moduleId);
|
||||||
|
if (isNumber) {
|
||||||
if (result) {
|
const result = await downloadModule(moduleId);
|
||||||
const { filePath, fileName } = result;
|
if (result) {
|
||||||
|
const { filePath, fileName } = result;
|
||||||
await ctx.replyWithDocument({ source: filePath }, {
|
const regexExtension = /\.\w+$/i;
|
||||||
caption: fileName,
|
const hasExtension = regexExtension.test(fileName);
|
||||||
...({ reply_to_message_id })
|
if (hasExtension) {
|
||||||
});
|
await ctx.replyWithDocument({ source: filePath }, {
|
||||||
|
caption: fileName,
|
||||||
fs.unlinkSync(filePath);
|
...({ reply_to_message_id })
|
||||||
} else {
|
});
|
||||||
ctx.reply(Strings.maDownloadError, {
|
fs.unlinkSync(filePath);
|
||||||
parse_mode: "Markdown",
|
return;
|
||||||
...({ reply_to_message_id })
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
return ctx.reply(Strings.maInvalidModule, {
|
||||||
|
parse_mode: "Markdown",
|
||||||
|
...({ reply_to_message_id })
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue