update convert-units and add disclaimer, temporary command for testing arguments

This commit is contained in:
Evert Prants 2021-10-19 19:59:10 +03:00
parent d421913104
commit a2f2064a2f
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
7 changed files with 35 additions and 332 deletions

View File

@ -2,7 +2,7 @@
"main": "plugin.js", "main": "plugin.js",
"name": "fun", "name": "fun",
"description": "Fun commands", "description": "Fun commands",
"version": "1.0.0", "version": "1.0.1",
"tags": ["commands", "fun"], "tags": ["commands", "fun"],
"dependencies": ["simplecommands"], "dependencies": ["simplecommands"],
"npmDependencies": [] "npmDependencies": []

View File

@ -27,7 +27,11 @@ class FunPlugin extends Plugin {
this.on('message', (data: IMessage) => { this.on('message', (data: IMessage) => {
const messageRefined = data.text.toLowerCase().trim().replace(/@/g, ''); const messageRefined = data.text.toLowerCase().trim().replace(/@/g, '');
const myName = data.source.me.name.toLowerCase(); 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 <!${myID}>`)) {
// Add a little bit of delay (personal preference) // Add a little bit of delay (personal preference)
setTimeout(() => { setTimeout(() => {
if (data.sender) { if (data.sender) {

330
package-lock.json generated
View File

@ -11,7 +11,7 @@
"dependencies": { "dependencies": {
"@squeebot/core": "^3.3.1", "@squeebot/core": "^3.3.1",
"cheerio": "^1.0.0-rc.10", "cheerio": "^1.0.0-rc.10",
"convert-units": "^2.3.4", "convert-units": "^3.0.0-beta.2",
"gamedig": "^3.0.7", "gamedig": "^3.0.7",
"mathjs": "^9.4.4", "mathjs": "^9.4.4",
"node-ical": "^0.13.0", "node-ical": "^0.13.0",
@ -321,13 +321,9 @@
} }
}, },
"node_modules/convert-units": { "node_modules/convert-units": {
"version": "2.3.4", "version": "3.0.0-beta.2",
"resolved": "https://registry.npmjs.org/convert-units/-/convert-units-2.3.4.tgz", "resolved": "https://registry.npmjs.org/convert-units/-/convert-units-3.0.0-beta.2.tgz",
"integrity": "sha512-ERHfdA0UhHJp1IpwE6PnFJx8LqG7B1ZjJ20UvVCmopEnVCfER68Tbe3kvN63dLbYXDA2xFWRE6zd4Wsf0w7POg==", "integrity": "sha512-ib0pIcx+gMP/gpvMpZkol0MZr3mXTSLvt+BtspAB7Ff0QPo5VIJCcxmYd0GBnvV5i5B0lyySBZzkv/l3gWhx1A=="
"dependencies": {
"lodash.foreach": "2.3.x",
"lodash.keys": "2.3.x"
}
}, },
"node_modules/core-util-is": { "node_modules/core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -700,160 +696,6 @@
"json-buffer": "3.0.1" "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": { "node_modules/long": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
@ -1524,13 +1366,9 @@
} }
}, },
"convert-units": { "convert-units": {
"version": "2.3.4", "version": "3.0.0-beta.2",
"resolved": "https://registry.npmjs.org/convert-units/-/convert-units-2.3.4.tgz", "resolved": "https://registry.npmjs.org/convert-units/-/convert-units-3.0.0-beta.2.tgz",
"integrity": "sha512-ERHfdA0UhHJp1IpwE6PnFJx8LqG7B1ZjJ20UvVCmopEnVCfER68Tbe3kvN63dLbYXDA2xFWRE6zd4Wsf0w7POg==", "integrity": "sha512-ib0pIcx+gMP/gpvMpZkol0MZr3mXTSLvt+BtspAB7Ff0QPo5VIJCcxmYd0GBnvV5i5B0lyySBZzkv/l3gWhx1A=="
"requires": {
"lodash.foreach": "2.3.x",
"lodash.keys": "2.3.x"
}
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@ -1807,160 +1645,6 @@
"json-buffer": "3.0.1" "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": { "long": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",

View File

@ -13,7 +13,7 @@
"dependencies": { "dependencies": {
"@squeebot/core": "^3.3.1", "@squeebot/core": "^3.3.1",
"cheerio": "^1.0.0-rc.10", "cheerio": "^1.0.0-rc.10",
"convert-units": "^2.3.4", "convert-units": "^3.0.0-beta.2",
"gamedig": "^3.0.7", "gamedig": "^3.0.7",
"mathjs": "^9.4.4", "mathjs": "^9.4.4",
"node-ical": "^0.13.0", "node-ical": "^0.13.0",

View File

@ -15,7 +15,7 @@
}, },
{ {
"name": "fun", "name": "fun",
"version": "1.0.0" "version": "1.0.1"
}, },
{ {
"name": "gamedig", "name": "gamedig",
@ -43,7 +43,7 @@
}, },
{ {
"name": "utility", "name": "utility",
"version": "3.1.4" "version": "3.1.6"
} }
], ],
"typescript": true "typescript": true

View File

@ -2,11 +2,11 @@
"main": "plugin.js", "main": "plugin.js",
"name": "utility", "name": "utility",
"description": "Utility commands and math operations", "description": "Utility commands and math operations",
"version": "3.1.4", "version": "3.1.6",
"tags": ["commands", "tools"], "tags": ["commands", "tools"],
"dependencies": ["simplecommands"], "dependencies": ["simplecommands"],
"npmDependencies": [ "npmDependencies": [
"mathjs@^9.4.4", "mathjs@^9.4.4",
"convert-units@^2.3.4" "convert-units@^3.0.0-beta.2"
] ]
} }

View File

@ -1,7 +1,7 @@
import path from 'path'; import path from 'path';
import net from 'net'; import net from 'net';
import cprog from 'child_process'; import cprog from 'child_process';
import convert from 'convert-units'; import configureMeasurements, { allMeasures } from 'convert-units';
import { import {
Plugin, Plugin,
@ -17,6 +17,8 @@ import { logger } from '@squeebot/core/lib/core';
type CEXResponse = {[key: string]: number}; type CEXResponse = {[key: string]: number};
const convert = configureMeasurements(allMeasures);
const cexCache: {[key: string]: number | CEXResponse} = { const cexCache: {[key: string]: number | CEXResponse} = {
expiry: 0, expiry: 0,
date: 0, date: 0,
@ -651,7 +653,7 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
msg.resolve('Failed to convert.'); msg.resolve('Failed to convert.');
return true; return true;
}, },
description: 'Convert between quantities in different units.', description: 'Convert between quantities in different units (abbreviations only).',
usage: '<number> <from unit> <to unit>', usage: '<number> <from unit> <to unit>',
aliases: ['cv', 'unit'] aliases: ['cv', 'unit']
}); });
@ -776,6 +778,19 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
aliases: ['rnum', 'rand', 'rng'] 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<boolean> => {
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) => { commands.registerCommand(cmds.map((x: any) => {
x.plugin = plugin.manifest.name; x.plugin = plugin.manifest.name;
return x; return x;