weirdness

This commit is contained in:
Evert Prants 2022-03-08 21:07:25 +02:00
parent 1406f46b2e
commit 60b55f582b
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 228 additions and 76 deletions

View File

@ -43,7 +43,7 @@
}, },
{ {
"name": "utility", "name": "utility",
"version": "3.1.10" "version": "3.2.1"
} }
], ],
"typescript": true "typescript": true

View File

@ -2,9 +2,14 @@
"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.10", "version": "3.2.1",
"tags": ["commands", "tools"], "tags": [
"dependencies": ["simplecommands"], "commands",
"tools"
],
"dependencies": [
"simplecommands"
],
"npmDependencies": [ "npmDependencies": [
"mathjs@^9.4.4", "mathjs@^9.4.4",
"convert-units@^3.0.0-beta.2" "convert-units@^3.0.0-beta.2"

View File

@ -6,11 +6,15 @@ import {
Plugin, Plugin,
Configurable, Configurable,
EventListener, EventListener,
DependencyLoad DependencyLoad,
} from '@squeebot/core/lib/plugin'; } from '@squeebot/core/lib/plugin';
import { IMessage, MessageResolver } from '@squeebot/core/lib/types'; import { IMessage, MessageResolver } from '@squeebot/core/lib/types';
import { httpGET, parseTimeToSeconds, readableTime } from '@squeebot/core/lib/common'; import {
httpGET,
parseTimeToSeconds,
readableTime,
} from '@squeebot/core/lib/common';
import { logger } from '@squeebot/core/lib/core'; import { logger } from '@squeebot/core/lib/core';
import { import {
@ -24,17 +28,11 @@ import {
ASCIIBinaryConverter, ASCIIBinaryConverter,
ASCIIHexConverter, ASCIIHexConverter,
base64Converter, base64Converter,
baseConverter baseConverter,
} from './convert'; } from './convert';
type CEXResponse = { [key: string]: number }; type CEXResponse = { [key: string]: number };
const cexCache: { [key: string]: number | CEXResponse } = {
expiry: 0,
date: 0,
cache: {},
};
// Run mathjs in a separate thread to avoid the killing of the main process // Run mathjs in a separate thread to avoid the killing of the main process
function opMath(expression: string): Promise<string> { function opMath(expression: string): Promise<string> {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -103,7 +101,7 @@ function pingTcpServer(host: string, port: number): Promise<number> {
} }
} }
const pingHost = net.connect({port, host}, () => { const pingHost = net.connect({ port, host }, () => {
timeA = new Date().getTime(); timeA = new Date().getTime();
returnResults(true, timeA - timeB); returnResults(true, timeA - timeB);
pingHost.end(); pingHost.end();
@ -135,7 +133,13 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
cmds.push({ cmds.push({
name: 'binary', name: 'binary',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
try { try {
const result = ASCIIBinaryConverter(msg.text, simplified); const result = ASCIIBinaryConverter(msg.text, simplified);
msg.resolve(`> ${result}`); msg.resolve(`> ${result}`);
@ -145,12 +149,18 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
}, },
description: 'Encode/decode binary (ASCII only)', description: 'Encode/decode binary (ASCII only)',
usage: '<ENCODE/DECODE> <message>' usage: '<ENCODE/DECODE> <message>',
}); });
cmds.push({ cmds.push({
name: 'hexstr', name: 'hexstr',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
try { try {
const result = ASCIIHexConverter(msg.text, simplified); const result = ASCIIHexConverter(msg.text, simplified);
msg.resolve(`> ${result}`); msg.resolve(`> ${result}`);
@ -160,12 +170,18 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
}, },
description: 'Encode/decode hexadecimal (ASCII only)', description: 'Encode/decode hexadecimal (ASCII only)',
usage: '<ENCODE/DECODE> <string>' usage: '<ENCODE/DECODE> <string>',
}); });
cmds.push({ cmds.push({
name: 'base64', name: 'base64',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
try { try {
const result = base64Converter(msg.text, simplified); const result = base64Converter(msg.text, simplified);
msg.resolve(`> ${result}`); msg.resolve(`> ${result}`);
@ -175,12 +191,18 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
}, },
description: 'Encode/decode base64 (ASCII only)', description: 'Encode/decode base64 (ASCII only)',
usage: '<ENCODE/DECODE> <string>' usage: '<ENCODE/DECODE> <string>',
}); });
cmds.push({ cmds.push({
name: 'numsys', name: 'numsys',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
try { try {
const result = baseConverter(simplified); const result = baseConverter(simplified);
msg.resolve(`> ${result}`); msg.resolve(`> ${result}`);
@ -191,23 +213,35 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
}, },
description: 'Convert a value into a value in another numbering system.', description: 'Convert a value into a value in another numbering system.',
usage: '<value> <bin/dec/hex/oct> <bin/dec/hex/oct>', usage: '<value> <bin/dec/hex/oct> <bin/dec/hex/oct>',
aliases: ['convertnumbers', 'cvnums'] aliases: ['convertnumbers', 'cvnums'],
}); });
cmds.push({ cmds.push({
name: 'convertseconds', name: 'convertseconds',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
msg.resolve(readableTime(parseInt(simplified[0], 10))); msg.resolve(readableTime(parseInt(simplified[0], 10)));
return true; return true;
}, },
description: 'Convert seconds to years days hours minutes seconds.', description: 'Convert seconds to years days hours minutes seconds.',
usage: '<seconds>', usage: '<seconds>',
aliases: ['cvs', 'parseseconds'] aliases: ['cvs', 'parseseconds'],
}); });
cmds.push({ cmds.push({
name: 'converttime', name: 'converttime',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
const str = msg.text.split(' ').slice(1).join(' '); const str = msg.text.split(' ').slice(1).join(' ');
if (!str) { if (!str) {
@ -219,13 +253,20 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
}, },
description: 'Convert ywdhms to seconds.', description: 'Convert ywdhms to seconds.',
usage: '[<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s]', usage:
aliases: ['cvt', 'parsetime'] '[<years>y] [<weeks>w] [<days>d] [<hours>h] [<minutes>m] [<seconds>s]',
aliases: ['cvt', 'parsetime'],
}); });
cmds.push({ cmds.push({
name: 'reconverttime', name: 'reconverttime',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
const str = msg.text.split(' ').slice(1).join(' '); const str = msg.text.split(' ').slice(1).join(' ');
if (!str) { if (!str) {
@ -238,12 +279,18 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
}, },
aliases: ['rcvt'] aliases: ['rcvt'],
}); });
cmds.push({ cmds.push({
name: 'eval', name: 'eval',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
if (!simplified[0]) { if (!simplified[0]) {
return true; return true;
} }
@ -261,55 +308,83 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
}, },
aliases: ['math', 'calc'], aliases: ['math', 'calc'],
usage: '<expression>', usage: '<expression>',
description: 'Evaluate a math expression (See https://mathjs.org/)' description: 'Evaluate a math expression (See https://mathjs.org/)',
}); });
cmds.push({ cmds.push({
name: 'userid', name: 'userid',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
msg.resolve('Your userId is %s.', msg.fullSenderID); msg.resolve('Your userId is %s.', msg.fullSenderID);
return true; return true;
}, },
description: 'Display your userId (internal user identification)', description: 'Display your userId (internal user identification)',
hidden: true hidden: true,
}); });
cmds.push({ cmds.push({
name: 'roomid', name: 'roomid',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
msg.resolve('Current roomId is %s.', msg.fullRoomID); msg.resolve('Current roomId is %s.', msg.fullRoomID);
return true; return true;
}, },
description: 'Display the internal identification of this room', description: 'Display the internal identification of this room',
hidden: true hidden: true,
}); });
cmds.push({ cmds.push({
name: 'serverid', name: 'serverid',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
if (msg.target && msg.target.server) { if (msg.target && msg.target.server) {
msg.resolve('Current server ID is s:%s.', msg.target.server); msg.resolve('Current server ID is s:%s.', msg.target.server);
return true; return true;
} }
msg.resolve('This protocol does not specify a server. ' + msg.resolve(
'Either the protocol is for a single server only or the server variable is not supported.'); 'This protocol does not specify a server. ' +
'Either the protocol is for a single server only or the server variable is not supported.'
);
return true; return true;
}, },
description: 'Display the internal identification of this room', description: 'Display the internal identification of this room',
hidden: true hidden: true,
}); });
cmds.push({ cmds.push({
name: 'rgb2hex', name: 'rgb2hex',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
if (!simplified[0]) { if (!simplified[0]) {
return true; return true;
} }
const fullmsg = msg.text.split(' ').slice(1).join(' '); const fullmsg = msg.text.split(' ').slice(1).join(' ');
const channels = fullmsg.match(/(rgb)?\(?(\d{1,3}),?\s(\d{1,3}),?\s(\d{1,3})\)?/i); const channels = fullmsg.match(
/(rgb)?\(?(\d{1,3}),?\s(\d{1,3}),?\s(\d{1,3})\)?/i
);
if (!channels || channels[2] == null) { if (!channels || channels[2] == null) {
msg.resolve('Invalid parameter'); msg.resolve('Invalid parameter');
return true; return true;
@ -328,18 +403,26 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
}, },
description: 'Convert RGB to HEX colors', description: 'Convert RGB to HEX colors',
usage: '[rgb](<r>, <g>, <b>)|<r> <g> <b>' usage: '[rgb](<r>, <g>, <b>)|<r> <g> <b>',
}); });
cmds.push({ cmds.push({
name: 'rgb2hsl', name: 'rgb2hsl',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
if (!simplified[0]) { if (!simplified[0]) {
return true; return true;
} }
const fullmsg = msg.text.split(' ').slice(1).join(' '); const fullmsg = msg.text.split(' ').slice(1).join(' ');
const channels = fullmsg.match(/(rgb)?\(?(\d{1,3}),?\s(\d{1,3}),?\s(\d{1,3})\)?/i); const channels = fullmsg.match(
/(rgb)?\(?(\d{1,3}),?\s(\d{1,3}),?\s(\d{1,3})\)?/i
);
if (!channels || channels[2] == null) { if (!channels || channels[2] == null) {
msg.resolve('Invalid parameter'); msg.resolve('Invalid parameter');
return true; return true;
@ -359,12 +442,18 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
}, },
description: 'Convert RGB to HSL colors', description: 'Convert RGB to HSL colors',
usage: '[rgb](<r>, <g>, <b>)|<r> <g> <b>' usage: '[rgb](<r>, <g>, <b>)|<r> <g> <b>',
}); });
cmds.push({ cmds.push({
name: 'hex2rgb', name: 'hex2rgb',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
if (!simplified[0]) { if (!simplified[0]) {
return true; return true;
} }
@ -389,12 +478,18 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
}, },
description: 'Convert HEX to RGB colors', description: 'Convert HEX to RGB colors',
usage: '#<r><g><b>|#<rr><gg><bb>' usage: '#<r><g><b>|#<rr><gg><bb>',
}); });
cmds.push({ cmds.push({
name: 'isup', name: 'isup',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
if (!simplified[0]) { if (!simplified[0]) {
msg.resolve('Please specify host name!'); msg.resolve('Please specify host name!');
return true; return true;
@ -432,12 +527,18 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
description: 'Ping a host', description: 'Ping a host',
usage: '<host> <port>', usage: '<host> <port>',
aliases: ['tcpup', 'tping'], aliases: ['tcpup', 'tping'],
hidden: true hidden: true,
}); });
cmds.push({ cmds.push({
name: 'convert', name: 'convert',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
const tqnt = parseFloat(simplified[0]); const tqnt = parseFloat(simplified[0]);
if (isNaN(tqnt)) { if (isNaN(tqnt)) {
msg.resolve('Please specify a quantity, either an integer or a float!'); msg.resolve('Please specify a quantity, either an integer or a float!');
@ -484,8 +585,10 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
const srcdesc = convert().describe(src); const srcdesc = convert().describe(src);
const dstdesc = convert().describe(dst); const dstdesc = convert().describe(dst);
const bsrcdesc = (Math.floor(tqnt) !== 1) ? srcdesc.plural : srcdesc.singular; const bsrcdesc =
const bdstdesc = (Math.floor(res) !== 1) ? dstdesc.plural : dstdesc.singular; Math.floor(tqnt) !== 1 ? srcdesc.plural : srcdesc.singular;
const bdstdesc =
Math.floor(res) !== 1 ? dstdesc.plural : dstdesc.singular;
msg.resolve(` ${tqnt} ${bsrcdesc} => ${res} ${bdstdesc}`); msg.resolve(` ${tqnt} ${bsrcdesc} => ${res} ${bdstdesc}`);
return true; return true;
@ -496,14 +599,20 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
}, },
description: 'Convert between quantities in different units.', description: 'Convert between quantities in different units.',
usage: '<number> <from unit> <to unit>', usage: '<number> <from unit> <to unit>',
aliases: ['cv', 'unit'] aliases: ['cv', 'unit'],
}); });
cmds.push({ cmds.push({
name: 'currency', name: 'currency',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
let ctw: CEXResponse | null = cexCache.cache as CEXResponse; msg: IMessage,
if (cexCache.expiry < Date.now()) { msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
let ctw: CEXResponse | null = plugin.cexCache.cache as CEXResponse;
if (plugin.cexCache.expiry < Date.now()) {
let fetched; let fetched;
try { try {
const data = await httpGET('https://api.exchangerate.host/latest'); const data = await httpGET('https://api.exchangerate.host/latest');
@ -514,21 +623,29 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
} }
if (!ctw || !fetched.rates) { if (!ctw || !fetched.rates) {
msg.resolve('Could not fetch currency exchange rates at this time. Please try again later.'); msg.resolve(
'Could not fetch currency exchange rates at this time. Please try again later.'
);
return true; return true;
} }
cexCache.cache = fetched.rates; plugin.cexCache.cache = fetched.rates;
cexCache.date = fetched.date; plugin.cexCache.date = fetched.date;
cexCache.expiry = Date.now() + 86400000; // day plugin.cexCache.expiry = Date.now() + 86400000; // day
ctw = cexCache.cache as CEXResponse; ctw = plugin.cexCache.cache as CEXResponse;
} }
if (simplified[0] === 'date') { if (simplified[0] === 'date') {
msg.resolve('Currency exchange rates are as of %s', cexCache.date); msg.resolve(
'Currency exchange rates are as of %s',
plugin.cexCache.date
);
return true; return true;
} else if (simplified[0] === 'list') { } else if (simplified[0] === 'list') {
msg.resolve('Currently supported currencies: EUR, %s', Object.keys(cexCache.cache).join(', ')); msg.resolve(
'Currently supported currencies: EUR, %s',
Object.keys(plugin.cexCache.cache).join(', ')
);
return true; return true;
} }
@ -568,18 +685,24 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
return true; return true;
} }
const amnt = (ctw[t] * n / ctw[f]).toFixed(4); const amnt = ((ctw[t] * n) / ctw[f]).toFixed(4);
msg.resolve('%f %s => %f %s', n, f, amnt, t); msg.resolve('%f %s => %f %s', n, f, amnt, t);
return true; return true;
}, },
description: 'Convert between currencies.', description: 'Convert between currencies.',
usage: '<number> | [date | list] [<from currency>] [<to currency>]', usage: '<number> | [date | list] [<from currency>] [<to currency>]',
aliases: ['cex', 'exchange'] aliases: ['cex', 'exchange'],
}); });
cmds.push({ cmds.push({
name: 'randomnumber', name: 'randomnumber',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
if (simplified.length < 2) { if (simplified.length < 2) {
msg.resolve('Too few arguments!'); msg.resolve('Too few arguments!');
return true; return true;
@ -598,8 +721,13 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
min = max; min = max;
max = realMax; max = realMax;
} }
if (isNaN(count)) { count = 1; } if (isNaN(count)) {
if (String(Math.abs(min)).length > 9 || String(Math.abs(max)).length > 9) { count = 1;
}
if (
String(Math.abs(min)).length > 9 ||
String(Math.abs(max)).length > 9
) {
msg.resolve('The numbers are too large!'); msg.resolve('The numbers are too large!');
return true; return true;
} }
@ -616,15 +744,23 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
}, },
description: 'Generate a random number between <min> and <max>.', description: 'Generate a random number between <min> and <max>.',
usage: '<min> <max> [<count>]', usage: '<min> <max> [<count>]',
aliases: ['rnum', 'rand', 'rng'] aliases: ['rnum', 'rand', 'rng'],
}); });
// FIXME: temporary code for removal // FIXME: temporary code for removal
cmds.push({ cmds.push({
name: 'cmtest', name: 'cmtest',
execute: async (msg: IMessage, msr: MessageResolver, spec: any, prefix: string, ...simplified: any[]): Promise<boolean> => { execute: async (
msg: IMessage,
msr: MessageResolver,
spec: any,
prefix: string,
...simplified: any[]
): Promise<boolean> => {
console.log(simplified); console.log(simplified);
msg.resolve(`argument 1: '${simplified[0]}' argument 2: '${simplified[1]}'`); msg.resolve(
`argument 1: '${simplified[0]}' argument 2: '${simplified[1]}'`
);
return true; return true;
}, },
description: 'Test the command argument parser', description: 'Test the command argument parser',
@ -632,17 +768,25 @@ function addCommands(plugin: UtilityPlugin, commands: any): void {
hidden: true, hidden: true,
}); });
commands.registerCommand(cmds.map((x: any) => { commands.registerCommand(
x.plugin = plugin.manifest.name; cmds.map((x: any) => {
return x; x.plugin = plugin.manifest.name;
})); return x;
})
);
} }
@Configurable({ @Configurable({
ipfsGateway: 'https://ipfs.io', ipfsGateway: 'https://ipfs.io',
randomMax: 64 randomMax: 64,
}) })
class UtilityPlugin extends Plugin { class UtilityPlugin extends Plugin {
public cexCache: { [key: string]: number | CEXResponse } = {
expiry: 0,
date: 0,
cache: {},
};
@DependencyLoad('simplecommands') @DependencyLoad('simplecommands')
addCommands(cmd: any): void { addCommands(cmd: any): void {
addCommands(this, cmd); addCommands(this, cmd);
@ -652,6 +796,9 @@ class UtilityPlugin extends Plugin {
public unloadEventHandler(plugin: string | Plugin): void { public unloadEventHandler(plugin: string | Plugin): void {
if (plugin === this.name || plugin === this) { if (plugin === this.name || plugin === this) {
wipeCaches(); wipeCaches();
this.cexCache.expiry = 0;
this.cexCache.date = 0;
this.cexCache.cache = {};
this.emit('pluginUnloaded', this); this.emit('pluginUnloaded', this);
} }
} }