ref: create separated verifyUserInput function

This commit is contained in:
GiovaniFZ 2025-03-09 12:46:47 -03:00
parent 4c02ebc265
commit 9535c69dbc
No known key found for this signature in database
GPG key ID: 63DD92181B575322
4 changed files with 30 additions and 41 deletions

View file

@ -6,6 +6,7 @@ const Resources = require('../props/resources.json');
const axios = require('axios');
const { getStrings } = require('../plugins/checklang.js');
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
const { verifyInput } = require('../plugins/verifyInput.js');
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
const statusEmojis = {
@ -35,12 +36,10 @@ module.exports = (bot) => {
const userLang = ctx.from.language_code || "en-US";
const Strings = getStrings(userLang);
const userInput = ctx.message.text.split(' ').slice(1).join(' ');
const { provideLocation } = Strings.weatherStatus
if (!userInput) {
return ctx.reply(Strings.weatherStatus.provideLocation, {
parse_mode: "Markdown",
reply_to_message_id: ctx.message.message_id
});
if (verifyInput(ctx, userInput, provideLocation)) {
return;
}
const location = userInput;
@ -95,7 +94,7 @@ module.exports = (bot) => {
.replace('{windSpeed}', windSpeed)
.replace('{speedUnit}', speedUnit);
ctx.reply(weatherMessage, {
ctx.reply(weatherMessage, {
parse_mode: "Markdown",
reply_to_message_id: ctx.message.message_id
});