Skip to content

Commit

Permalink
Fixed lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurvir committed Apr 9, 2024
1 parent cc6065d commit 3c0af53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controllers/Bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ async function process_text(req, res) {
}
else if(ai.action?.action === 'clear_all'){
session = EMPTY_SESSION;
response.formatted = get_text_by_key(session_and_profile_cleared);
response.formatted = get_text_by_key('session_and_profile_cleared');
}
else if(ai.action?.action === 'get_routes'){
const routes = await mapService.generate_routes(message, session.text, session.avoid_point|| []);
Expand Down
5 changes: 3 additions & 2 deletions utils/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ const language = JSON.parse(readFileSync('./config/language.json'))
function get_text_by_key(key, variables = {}, category='ALL_MESSAGES'){
let text = language[category][key] || null;
if (text) {
text = text.replace(/\$\{(\w+)\}/g, (match, variableName) => {
return variables.hasOwnProperty(variableName) ? variables[variableName] : match;
Object.keys(variables).forEach(variable => {
/* eslint no-useless-escape: "off" */
text = text.replace(new RegExp(`\\$\{${variable}\}`, 'g'), variables[variable]);
});
}
return text;
Expand Down

0 comments on commit 3c0af53

Please sign in to comment.