mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
Put all strings of /weather on another JSON object
This commit is contained in:
parent
39f22ccf96
commit
629401dee8
@ -35,16 +35,16 @@ module.exports = (bot) => {
|
||||
bot.command(['clima', 'weather'], spamwatchMiddleware, async (ctx) => {
|
||||
const userLang = ctx.from.language_code || "en-US";
|
||||
const Strings = getStrings(userLang);
|
||||
const args = ctx.message.text;
|
||||
const userInput = ctx.message.text.split(' ').slice(1).join(' ');
|
||||
|
||||
if (args.length < 9) {
|
||||
return ctx.reply(Strings.weatherProvideLocation, {
|
||||
if (!userInput) {
|
||||
return ctx.reply(Strings.weatherStatus.provideLocation, {
|
||||
parse_mode: "Markdown",
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
}
|
||||
|
||||
const location = args.slice(9);
|
||||
const location = userInput;
|
||||
const apiKey = process.env.weatherKey;
|
||||
|
||||
try {
|
||||
@ -59,7 +59,7 @@ module.exports = (bot) => {
|
||||
|
||||
const locationData = locationResponse.data.location;
|
||||
if (!locationData || !locationData.address) {
|
||||
return ctx.reply(Strings.weatherInvalidLocation, {
|
||||
return ctx.reply(Strings.weatherStatus.invalidLocation, {
|
||||
parse_mode: "Markdown",
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
@ -83,7 +83,7 @@ module.exports = (bot) => {
|
||||
const weatherData = weatherResponse.data['v3-wx-observations-current'];
|
||||
const { temperature, temperatureFeelsLike, relativeHumidity, windSpeed, iconCode, wxPhraseLong } = weatherData;
|
||||
|
||||
const weatherMessage = Strings.weatherStatus
|
||||
const weatherMessage = Strings.weatherStatus.resultMsg
|
||||
.replace('{addressFirst}', addressFirst)
|
||||
.replace('{getStatusEmoji(iconCode)}', getStatusEmoji(iconCode))
|
||||
.replace('{wxPhraseLong}', wxPhraseLong)
|
||||
@ -100,7 +100,7 @@ module.exports = (bot) => {
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
});
|
||||
} catch (error) {
|
||||
const message = Strings.weatherErr.replace('{error}', error.message);
|
||||
const message = Strings.weatherStatus.apiErr.replace('{error}', error.message);
|
||||
ctx.reply(message, {
|
||||
parse_mode: "Markdown",
|
||||
reply_to_message_id: ctx.message.message_id
|
||||
|
@ -47,10 +47,12 @@
|
||||
"lastFmErr": "*Error retrieving data for Last.fm user* {lastfmUser}.\n\n`{err}`",
|
||||
"gitCurrentCommit": "*Current commit:* `{commitHash}`",
|
||||
"gitErrRetrievingCommit": "*Error retrieving commit:* {error}",
|
||||
"weatherProvideLocation": "*Please provide a location.*",
|
||||
"weatherInvalidLocation": "*Invalid location. Try again.*",
|
||||
"weatherStatus": "*Weather in {addressFirst}:*\n\n*Status:* `{getStatusEmoji(iconCode)} {wxPhraseLong}`\n*Temperature:* `{temperature} °{temperatureUnit}`\n*Feels like:* `{temperatureFeelsLike} °{temperatureUnit2}`\n*Humidity:* `{relativeHumidity}%`\n*Wind speed:* `{windSpeed} {speedUnit}`",
|
||||
"weatherErr": "*An error occurred while retrieving the weather. Please try again later.*\n\n`{error}`",
|
||||
"weatherStatus": {
|
||||
"provideLocation": "*Please provide a location.*",
|
||||
"invalidLocation": "*Invalid location. Try again.*",
|
||||
"resultMsg": "*Weather in {addressFirst}:*\n\n*Status:* `{getStatusEmoji(iconCode)} {wxPhraseLong}`\n*Temperature:* `{temperature} °{temperatureUnit}`\n*Feels like:* `{temperatureFeelsLike} °{temperatureUnit2}`\n*Humidity:* `{relativeHumidity}%`\n*Wind speed:* `{windSpeed} {speedUnit}`",
|
||||
"apiErr": "*An error occurred while retrieving the weather. Please try again later.*\n\n`{error}`"
|
||||
},
|
||||
"mainCommands": "Main commands",
|
||||
"mainCommandsDesc": "*Main commands*\n\n- /help: Show bot's help\n- /start: Start the bot\n- /privacy: Read the bot's Privacy Policy",
|
||||
"usefulCommands": "Useful commands",
|
||||
|
@ -47,10 +47,12 @@
|
||||
"lastFmErr": "*Erro ao recuperar dados para o usuário do Last.fm* {lastfmUser}.\n\n`{err}`",
|
||||
"gitCurrentCommit": "*Commit atual:* `{commitHash}`",
|
||||
"gitErrRetrievingCommit": "*Erro ao obter o commit:*\n\n`{error}`",
|
||||
"weatherProvideLocation": "*Por favor, forneça uma localização.*",
|
||||
"weatherInvalidLocation": "*Localização inválida. Tente novamente.*",
|
||||
"weatherStatus": "*Clima em {addressFirst}:*\n\n*Estado:* `{getStatusEmoji(iconCode)} {wxPhraseLong}`\n*Temperatura:* `{temperature} °{temperatureUnit}`\n*Sensação térmica:* `{temperatureFeelsLike} °{temperatureUnit2}`\n*Umidade:* `{relativeHumidity}%`\n*Velocidade do vento:* `{windSpeed} {speedUnit}`",
|
||||
"weatherErr": "*Ocorreu um erro ao obter o clima. Tente novamente mais tarde.*\n\n`{error}`",
|
||||
"weatherStatus": {
|
||||
"provideLocation": "*Por favor, forneça uma localização.*",
|
||||
"invalidLocation": "*Localização inválida. Tente novamente.*",
|
||||
"resultMsg": "*Clima em {addressFirst}:*\n\n*Estado:* `{getStatusEmoji(iconCode)} {wxPhraseLong}`\n*Temperatura:* `{temperature} °{temperatureUnit}`\n*Sensação térmica:* `{temperatureFeelsLike} °{temperatureUnit2}`\n*Umidade:* `{relativeHumidity}%`\n*Velocidade do vento:* `{windSpeed} {speedUnit}`",
|
||||
"apiErr": "*Ocorreu um erro ao obter o clima. Tente novamente mais tarde.*\n\n`{error}`"
|
||||
},
|
||||
"mainCommands": "Comandos principais",
|
||||
"mainCommandsDesc": "*Comandos principais*\n\n- /help: Exibe a ajuda do bot\n- /start: Inicia o bot\n- /privacy: Leia a política de privacidade do bot",
|
||||
"usefulCommands": "Comandos úteis",
|
||||
|
Loading…
x
Reference in New Issue
Block a user