ref: create separated verifyUserInput function (#34)
Co-authored-by: Aidan <aidan@p0ntus.com> Co-authored-by: Lucas Gabriel <lucmsilva651@gmail.com>
This commit is contained in:
parent
e252a97696
commit
12ca87f4fe
4 changed files with 30 additions and 41 deletions
|
@ -3,19 +3,18 @@ const { getStrings } = require('../plugins/checklang.js');
|
|||
const { isOnSpamWatch } = require('../spamwatch/spamwatch.js');
|
||||
const spamwatchMiddleware = require('../spamwatch/Middleware.js')(isOnSpamWatch);
|
||||
const axios = require('axios');
|
||||
const { verifyInput } = require('../plugins/verifyInput.js');
|
||||
|
||||
module.exports = (bot) => {
|
||||
bot.command("http", spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
const userInput = ctx.message.text.split(' ')[1];
|
||||
const apiUrl = Resources.httpApi;
|
||||
const { invalidCode } = Strings.httpCodes
|
||||
|
||||
if (!userInput || isNaN(userInput)) {
|
||||
return ctx.reply(Strings.httpCodes.invalidCode, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
};
|
||||
if (verifyInput(ctx, userInput, invalidCode, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await axios.get(apiUrl);
|
||||
|
@ -50,12 +49,10 @@ module.exports = (bot) => {
|
|||
bot.command("httpcat", spamwatchMiddleware, async (ctx) => {
|
||||
const Strings = getStrings(ctx.from.language_code);
|
||||
const userInput = ctx.message.text.split(' ').slice(1).join(' ').replace(/\s+/g, '');
|
||||
|
||||
if (!userInput || isNaN(userInput)) {
|
||||
return ctx.reply(Strings.httpCodes.invalidCode, {
|
||||
parse_mode: 'Markdown',
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
const { invalidCode } = Strings.httpCodes
|
||||
|
||||
if (verifyInput(ctx, userInput, invalidCode, true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const apiUrl = `${Resources.httpCatApi}${userInput}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue