From 32c041cb4fd943f79a06bb22605ff7c722b784e2 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Tue, 19 Oct 2021 20:53:55 +0300 Subject: [PATCH] more advanced unit aliasing --- squeebot.repo.json | 2 +- utility/plugin.json | 2 +- utility/plugin.ts | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/squeebot.repo.json b/squeebot.repo.json index 6340a66..1b07b9c 100644 --- a/squeebot.repo.json +++ b/squeebot.repo.json @@ -43,7 +43,7 @@ }, { "name": "utility", - "version": "3.1.7" + "version": "3.1.10" } ], "typescript": true diff --git a/utility/plugin.json b/utility/plugin.json index 000ebd8..d066008 100644 --- a/utility/plugin.json +++ b/utility/plugin.json @@ -2,7 +2,7 @@ "main": "plugin.js", "name": "utility", "description": "Utility commands and math operations", - "version": "3.1.7", + "version": "3.1.10", "tags": ["commands", "tools"], "dependencies": ["simplecommands"], "npmDependencies": [ diff --git a/utility/plugin.ts b/utility/plugin.ts index d0ab7a0..fa86824 100644 --- a/utility/plugin.ts +++ b/utility/plugin.ts @@ -236,10 +236,12 @@ function createUnitIndex(): void { abbr, singular.toLowerCase(), plural.toLowerCase() ]; + // liter <-> litres if (abbr === 'l') { unitIndex[abbr].push('liter', 'liters'); } + // meter -> metre if (singular.includes('meter')) { unitIndex[abbr].push( singular.replace('meter', 'metre').toLowerCase(), @@ -247,6 +249,23 @@ function createUnitIndex(): void { ); } + // metre -> meter + if (singular.includes('metre')) { + unitIndex[abbr].push( + singular.replace('metre', 'meter').toLowerCase(), + plural.replace('metre', 'meter').toLowerCase(), + ); + } + + // " per " -> "/" + const appendages: string[] = []; + unitIndex[abbr].forEach((entry) => { + if (entry.includes(' per ')) { + appendages.push(entry.replace(' per ', '/')); + } + }); + unitIndex[abbr].push(...appendages); + backupLowercaseUnitTable[abbr.toLowerCase()] = abbr; } });