KOW-7 fix: better validation

This commit is contained in:
Aidan 2025-06-27 18:19:30 -04:00
parent 88e1f9fb42
commit ea0ae1a47d
3 changed files with 30 additions and 0 deletions

View file

@ -74,6 +74,15 @@ export default (bot: Telegraf<Context>) => {
return;
}
// if special characters or numbers (max 30 characters)
if (/[^a-zA-Z\s]/.test(userInput) || userInput.length > 30) {
ctx.reply(Strings.mlpInvalidCharacter, {
parse_mode: 'Markdown',
...({ reply_to_message_id })
});
return;
}
const capitalizedInput = capitalizeFirstLetter(userInput);
const apiUrl = `${Resources.ponyApi}/character/${capitalizedInput}`;
@ -148,6 +157,14 @@ export default (bot: Telegraf<Context>) => {
return;
}
if (Number(userInput) > 100) {
ctx.reply(Strings.mlpInvalidEpisode, {
parse_mode: 'Markdown',
...({ reply_to_message_id })
});
return;
}
const apiUrl = `${Resources.ponyApi}/episode/by-overall/${userInput}`;
try {
@ -218,6 +235,15 @@ export default (bot: Telegraf<Context>) => {
return;
};
// if special characters or numbers (max 30 characters)
if (/[^a-zA-Z\s]/.test(userInput) || userInput.length > 30) {
ctx.reply(Strings.mlpInvalidCharacter, {
parse_mode: 'Markdown',
...({ reply_to_message_id })
});
return;
}
const apiUrl = `${Resources.ponyApi}/comics-story/${userInput}`;
try {