From a2f2064a2f6d51fef35e84d7d70e632f12a57ff3 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Tue, 19 Oct 2021 19:59:10 +0300 Subject: [PATCH] update convert-units and add disclaimer, temporary command for testing arguments --- fun/plugin.json | 2 +- fun/plugin.ts | 6 +- package-lock.json | 330 +------------------------------------------- package.json | 2 +- squeebot.repo.json | 4 +- utility/plugin.json | 4 +- utility/plugin.ts | 19 ++- 7 files changed, 35 insertions(+), 332 deletions(-) diff --git a/fun/plugin.json b/fun/plugin.json index 485892f..b077baf 100644 --- a/fun/plugin.json +++ b/fun/plugin.json @@ -2,7 +2,7 @@ "main": "plugin.js", "name": "fun", "description": "Fun commands", - "version": "1.0.0", + "version": "1.0.1", "tags": ["commands", "fun"], "dependencies": ["simplecommands"], "npmDependencies": [] diff --git a/fun/plugin.ts b/fun/plugin.ts index 4181cb4..f11db09 100644 --- a/fun/plugin.ts +++ b/fun/plugin.ts @@ -27,7 +27,11 @@ class FunPlugin extends Plugin { this.on('message', (data: IMessage) => { const messageRefined = data.text.toLowerCase().trim().replace(/@/g, ''); const myName = data.source.me.name.toLowerCase(); - if (messageRefined.indexOf('hugs ' + myName) !== -1) { + const myID = data.source.me.id; + + // IRC and Discord support + if (messageRefined.includes(`hugs ${myName}`) + || messageRefined.includes(`hugs `)) { // Add a little bit of delay (personal preference) setTimeout(() => { if (data.sender) { diff --git a/package-lock.json b/package-lock.json index 342434a..c83349c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@squeebot/core": "^3.3.1", "cheerio": "^1.0.0-rc.10", - "convert-units": "^2.3.4", + "convert-units": "^3.0.0-beta.2", "gamedig": "^3.0.7", "mathjs": "^9.4.4", "node-ical": "^0.13.0", @@ -321,13 +321,9 @@ } }, "node_modules/convert-units": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/convert-units/-/convert-units-2.3.4.tgz", - "integrity": "sha512-ERHfdA0UhHJp1IpwE6PnFJx8LqG7B1ZjJ20UvVCmopEnVCfER68Tbe3kvN63dLbYXDA2xFWRE6zd4Wsf0w7POg==", - "dependencies": { - "lodash.foreach": "2.3.x", - "lodash.keys": "2.3.x" - } + "version": "3.0.0-beta.2", + "resolved": "https://registry.npmjs.org/convert-units/-/convert-units-3.0.0-beta.2.tgz", + "integrity": "sha512-ib0pIcx+gMP/gpvMpZkol0MZr3mXTSLvt+BtspAB7Ff0QPo5VIJCcxmYd0GBnvV5i5B0lyySBZzkv/l3gWhx1A==" }, "node_modules/core-util-is": { "version": "1.0.2", @@ -700,160 +696,6 @@ "json-buffer": "3.0.1" } }, - "node_modules/lodash._basebind": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._basebind/-/lodash._basebind-2.3.0.tgz", - "integrity": "sha1-K1vEUqDhBhQ7IYafIzvbWHQX0kg=", - "dependencies": { - "lodash._basecreate": "~2.3.0", - "lodash._setbinddata": "~2.3.0", - "lodash.isobject": "~2.3.0" - } - }, - "node_modules/lodash._basecreate": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-2.3.0.tgz", - "integrity": "sha1-m4ioak3P97fzxh2Dovz8BnHsneA=", - "dependencies": { - "lodash._renative": "~2.3.0", - "lodash.isobject": "~2.3.0", - "lodash.noop": "~2.3.0" - } - }, - "node_modules/lodash._basecreatecallback": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._basecreatecallback/-/lodash._basecreatecallback-2.3.0.tgz", - "integrity": "sha1-N7KrF1kaM56YjbMln81GAZ16w2I=", - "dependencies": { - "lodash._setbinddata": "~2.3.0", - "lodash.bind": "~2.3.0", - "lodash.identity": "~2.3.0", - "lodash.support": "~2.3.0" - } - }, - "node_modules/lodash._basecreatewrapper": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._basecreatewrapper/-/lodash._basecreatewrapper-2.3.0.tgz", - "integrity": "sha1-qgxhrZYETDkzN2ExSDqXWcNlEkc=", - "dependencies": { - "lodash._basecreate": "~2.3.0", - "lodash._setbinddata": "~2.3.0", - "lodash._slice": "~2.3.0", - "lodash.isobject": "~2.3.0" - } - }, - "node_modules/lodash._createwrapper": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._createwrapper/-/lodash._createwrapper-2.3.0.tgz", - "integrity": "sha1-0arhEC2t9EDo4G/BM6bt1/4UYHU=", - "dependencies": { - "lodash._basebind": "~2.3.0", - "lodash._basecreatewrapper": "~2.3.0", - "lodash.isfunction": "~2.3.0" - } - }, - "node_modules/lodash._objecttypes": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._objecttypes/-/lodash._objecttypes-2.3.0.tgz", - "integrity": "sha1-aj6jmH3W7rgCGy1cnDA1Scwrrh4=" - }, - "node_modules/lodash._renative": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._renative/-/lodash._renative-2.3.0.tgz", - "integrity": "sha1-d9jt1M7SbdWXH54Vpfdy5OMX+9M=" - }, - "node_modules/lodash._setbinddata": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._setbinddata/-/lodash._setbinddata-2.3.0.tgz", - "integrity": "sha1-5WEEkKzRMnfVmFjZW18nJ/FQjwQ=", - "dependencies": { - "lodash._renative": "~2.3.0", - "lodash.noop": "~2.3.0" - } - }, - "node_modules/lodash._shimkeys": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._shimkeys/-/lodash._shimkeys-2.3.0.tgz", - "integrity": "sha1-YR+TFJ4+bHIQlrSHae8pU3rai6k=", - "dependencies": { - "lodash._objecttypes": "~2.3.0" - } - }, - "node_modules/lodash._slice": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._slice/-/lodash._slice-2.3.0.tgz", - "integrity": "sha1-FHGYEyhZly5GgMoppZkshVZpqlw=" - }, - "node_modules/lodash.bind": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.bind/-/lodash.bind-2.3.0.tgz", - "integrity": "sha1-wqjhi2jl7MFS4rFoJmEW/qWwFsw=", - "dependencies": { - "lodash._createwrapper": "~2.3.0", - "lodash._renative": "~2.3.0", - "lodash._slice": "~2.3.0" - } - }, - "node_modules/lodash.foreach": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-2.3.0.tgz", - "integrity": "sha1-CDQEyR6EbudyRf3512UZxosq8Wg=", - "dependencies": { - "lodash._basecreatecallback": "~2.3.0", - "lodash.forown": "~2.3.0" - } - }, - "node_modules/lodash.forown": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.forown/-/lodash.forown-2.3.0.tgz", - "integrity": "sha1-JPtKr4ANRfwtxgv+w84EyDajrX8=", - "dependencies": { - "lodash._basecreatecallback": "~2.3.0", - "lodash._objecttypes": "~2.3.0", - "lodash.keys": "~2.3.0" - } - }, - "node_modules/lodash.identity": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.identity/-/lodash.identity-2.3.0.tgz", - "integrity": "sha1-awGiEMlIU1XCqRO0i2cRIZoXPe0=" - }, - "node_modules/lodash.isfunction": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-2.3.0.tgz", - "integrity": "sha1-aylz5HpkfPEucNZ2rqE2Q3BuUmc=" - }, - "node_modules/lodash.isobject": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-2.3.0.tgz", - "integrity": "sha1-LhbT/Fg9qYMZaJU/LY5tc0NPZ5k=", - "dependencies": { - "lodash._objecttypes": "~2.3.0" - } - }, - "node_modules/lodash.keys": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.3.0.tgz", - "integrity": "sha1-s1D0+Syqn0WkouzwGEVM8vKK4lM=", - "dependencies": { - "lodash._renative": "~2.3.0", - "lodash._shimkeys": "~2.3.0", - "lodash.isobject": "~2.3.0" - } - }, - "node_modules/lodash.noop": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.noop/-/lodash.noop-2.3.0.tgz", - "integrity": "sha1-MFnWKNUbv5N80qC2/Dp/ISpmnCw=" - }, - "node_modules/lodash.support": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.support/-/lodash.support-2.3.0.tgz", - "integrity": "sha1-fq8DivTw1qq3drRKptz8gDNMm/0=", - "dependencies": { - "lodash._renative": "~2.3.0" - } - }, "node_modules/long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", @@ -1524,13 +1366,9 @@ } }, "convert-units": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/convert-units/-/convert-units-2.3.4.tgz", - "integrity": "sha512-ERHfdA0UhHJp1IpwE6PnFJx8LqG7B1ZjJ20UvVCmopEnVCfER68Tbe3kvN63dLbYXDA2xFWRE6zd4Wsf0w7POg==", - "requires": { - "lodash.foreach": "2.3.x", - "lodash.keys": "2.3.x" - } + "version": "3.0.0-beta.2", + "resolved": "https://registry.npmjs.org/convert-units/-/convert-units-3.0.0-beta.2.tgz", + "integrity": "sha512-ib0pIcx+gMP/gpvMpZkol0MZr3mXTSLvt+BtspAB7Ff0QPo5VIJCcxmYd0GBnvV5i5B0lyySBZzkv/l3gWhx1A==" }, "core-util-is": { "version": "1.0.2", @@ -1807,160 +1645,6 @@ "json-buffer": "3.0.1" } }, - "lodash._basebind": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._basebind/-/lodash._basebind-2.3.0.tgz", - "integrity": "sha1-K1vEUqDhBhQ7IYafIzvbWHQX0kg=", - "requires": { - "lodash._basecreate": "~2.3.0", - "lodash._setbinddata": "~2.3.0", - "lodash.isobject": "~2.3.0" - } - }, - "lodash._basecreate": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-2.3.0.tgz", - "integrity": "sha1-m4ioak3P97fzxh2Dovz8BnHsneA=", - "requires": { - "lodash._renative": "~2.3.0", - "lodash.isobject": "~2.3.0", - "lodash.noop": "~2.3.0" - } - }, - "lodash._basecreatecallback": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._basecreatecallback/-/lodash._basecreatecallback-2.3.0.tgz", - "integrity": "sha1-N7KrF1kaM56YjbMln81GAZ16w2I=", - "requires": { - "lodash._setbinddata": "~2.3.0", - "lodash.bind": "~2.3.0", - "lodash.identity": "~2.3.0", - "lodash.support": "~2.3.0" - } - }, - "lodash._basecreatewrapper": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._basecreatewrapper/-/lodash._basecreatewrapper-2.3.0.tgz", - "integrity": "sha1-qgxhrZYETDkzN2ExSDqXWcNlEkc=", - "requires": { - "lodash._basecreate": "~2.3.0", - "lodash._setbinddata": "~2.3.0", - "lodash._slice": "~2.3.0", - "lodash.isobject": "~2.3.0" - } - }, - "lodash._createwrapper": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._createwrapper/-/lodash._createwrapper-2.3.0.tgz", - "integrity": "sha1-0arhEC2t9EDo4G/BM6bt1/4UYHU=", - "requires": { - "lodash._basebind": "~2.3.0", - "lodash._basecreatewrapper": "~2.3.0", - "lodash.isfunction": "~2.3.0" - } - }, - "lodash._objecttypes": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._objecttypes/-/lodash._objecttypes-2.3.0.tgz", - "integrity": "sha1-aj6jmH3W7rgCGy1cnDA1Scwrrh4=" - }, - "lodash._renative": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._renative/-/lodash._renative-2.3.0.tgz", - "integrity": "sha1-d9jt1M7SbdWXH54Vpfdy5OMX+9M=" - }, - "lodash._setbinddata": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._setbinddata/-/lodash._setbinddata-2.3.0.tgz", - "integrity": "sha1-5WEEkKzRMnfVmFjZW18nJ/FQjwQ=", - "requires": { - "lodash._renative": "~2.3.0", - "lodash.noop": "~2.3.0" - } - }, - "lodash._shimkeys": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._shimkeys/-/lodash._shimkeys-2.3.0.tgz", - "integrity": "sha1-YR+TFJ4+bHIQlrSHae8pU3rai6k=", - "requires": { - "lodash._objecttypes": "~2.3.0" - } - }, - "lodash._slice": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash._slice/-/lodash._slice-2.3.0.tgz", - "integrity": "sha1-FHGYEyhZly5GgMoppZkshVZpqlw=" - }, - "lodash.bind": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.bind/-/lodash.bind-2.3.0.tgz", - "integrity": "sha1-wqjhi2jl7MFS4rFoJmEW/qWwFsw=", - "requires": { - "lodash._createwrapper": "~2.3.0", - "lodash._renative": "~2.3.0", - "lodash._slice": "~2.3.0" - } - }, - "lodash.foreach": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.foreach/-/lodash.foreach-2.3.0.tgz", - "integrity": "sha1-CDQEyR6EbudyRf3512UZxosq8Wg=", - "requires": { - "lodash._basecreatecallback": "~2.3.0", - "lodash.forown": "~2.3.0" - } - }, - "lodash.forown": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.forown/-/lodash.forown-2.3.0.tgz", - "integrity": "sha1-JPtKr4ANRfwtxgv+w84EyDajrX8=", - "requires": { - "lodash._basecreatecallback": "~2.3.0", - "lodash._objecttypes": "~2.3.0", - "lodash.keys": "~2.3.0" - } - }, - "lodash.identity": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.identity/-/lodash.identity-2.3.0.tgz", - "integrity": "sha1-awGiEMlIU1XCqRO0i2cRIZoXPe0=" - }, - "lodash.isfunction": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.isfunction/-/lodash.isfunction-2.3.0.tgz", - "integrity": "sha1-aylz5HpkfPEucNZ2rqE2Q3BuUmc=" - }, - "lodash.isobject": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.isobject/-/lodash.isobject-2.3.0.tgz", - "integrity": "sha1-LhbT/Fg9qYMZaJU/LY5tc0NPZ5k=", - "requires": { - "lodash._objecttypes": "~2.3.0" - } - }, - "lodash.keys": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-2.3.0.tgz", - "integrity": "sha1-s1D0+Syqn0WkouzwGEVM8vKK4lM=", - "requires": { - "lodash._renative": "~2.3.0", - "lodash._shimkeys": "~2.3.0", - "lodash.isobject": "~2.3.0" - } - }, - "lodash.noop": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.noop/-/lodash.noop-2.3.0.tgz", - "integrity": "sha1-MFnWKNUbv5N80qC2/Dp/ISpmnCw=" - }, - "lodash.support": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/lodash.support/-/lodash.support-2.3.0.tgz", - "integrity": "sha1-fq8DivTw1qq3drRKptz8gDNMm/0=", - "requires": { - "lodash._renative": "~2.3.0" - } - }, "long": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", diff --git a/package.json b/package.json index 2ba68a4..ba7968e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "dependencies": { "@squeebot/core": "^3.3.1", "cheerio": "^1.0.0-rc.10", - "convert-units": "^2.3.4", + "convert-units": "^3.0.0-beta.2", "gamedig": "^3.0.7", "mathjs": "^9.4.4", "node-ical": "^0.13.0", diff --git a/squeebot.repo.json b/squeebot.repo.json index 85d58f4..e320e91 100644 --- a/squeebot.repo.json +++ b/squeebot.repo.json @@ -15,7 +15,7 @@ }, { "name": "fun", - "version": "1.0.0" + "version": "1.0.1" }, { "name": "gamedig", @@ -43,7 +43,7 @@ }, { "name": "utility", - "version": "3.1.4" + "version": "3.1.6" } ], "typescript": true diff --git a/utility/plugin.json b/utility/plugin.json index 8df1279..69b09bd 100644 --- a/utility/plugin.json +++ b/utility/plugin.json @@ -2,11 +2,11 @@ "main": "plugin.js", "name": "utility", "description": "Utility commands and math operations", - "version": "3.1.4", + "version": "3.1.6", "tags": ["commands", "tools"], "dependencies": ["simplecommands"], "npmDependencies": [ "mathjs@^9.4.4", - "convert-units@^2.3.4" + "convert-units@^3.0.0-beta.2" ] } diff --git a/utility/plugin.ts b/utility/plugin.ts index 8b9d4c1..0bb27c6 100644 --- a/utility/plugin.ts +++ b/utility/plugin.ts @@ -1,7 +1,7 @@ import path from 'path'; import net from 'net'; import cprog from 'child_process'; -import convert from 'convert-units'; +import configureMeasurements, { allMeasures } from 'convert-units'; import { Plugin, @@ -17,6 +17,8 @@ import { logger } from '@squeebot/core/lib/core'; type CEXResponse = {[key: string]: number}; +const convert = configureMeasurements(allMeasures); + const cexCache: {[key: string]: number | CEXResponse} = { expiry: 0, date: 0, @@ -651,7 +653,7 @@ function addCommands(plugin: UtilityPlugin, commands: any): void { msg.resolve('Failed to convert.'); return true; }, - description: 'Convert between quantities in different units.', + description: 'Convert between quantities in different units (abbreviations only).', usage: ' ', aliases: ['cv', 'unit'] }); @@ -776,6 +778,19 @@ function addCommands(plugin: UtilityPlugin, commands: any): void { aliases: ['rnum', 'rand', 'rng'] }); + // FIXME: temporary code for removal + cmds.push({ + name: 'cmtest', + execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise => { + console.log(simplified); + msg.resolve(`argument 1: '${simplified[0]}' argument 2: '${simplified[1]}'`); + return true; + }, + description: 'Test the command argument parser', + usage: '', + hidden: true, + }); + commands.registerCommand(cmds.map((x: any) => { x.plugin = plugin.manifest.name; return x;