new format args
This commit is contained in:
parent
0e827d1c85
commit
1e30598bc4
4 changed files with 212 additions and 218 deletions
4
bot.js
4
bot.js
|
@ -24,6 +24,10 @@ global.ctx = {
|
|||
set_ctx: (key, value) => {
|
||||
global.ctx[key] = value;
|
||||
},
|
||||
lights: {
|
||||
port: cfg.lights_port,
|
||||
addr: cfg.lights_address
|
||||
}
|
||||
};
|
||||
const log = new Logger(filename(import.meta.url), global.ctx.log_level);
|
||||
const parse = new CommandParser(global.ctx, cfg.prefix || undefined);
|
||||
|
|
|
@ -31,17 +31,26 @@ const available_targets = {
|
|||
class Instruction {
|
||||
constructor(name, targets, args) {
|
||||
let valid_targets = [];
|
||||
targets.forEach((t) => {
|
||||
let matched_args = [];
|
||||
targets.forEach((t, i) => {
|
||||
if (t instanceof Target) {
|
||||
let match = Object.keys(available_targets).find((key) => available_targets[key].channel === t.channel);
|
||||
if (match) {
|
||||
valid_targets.push(t);
|
||||
if (args[i]) {
|
||||
matched_args.push({
|
||||
...t,
|
||||
arg: args[i]
|
||||
})
|
||||
}
|
||||
else {
|
||||
matched_args.push(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.name = name;
|
||||
this.targets = valid_targets;
|
||||
this.args = args;
|
||||
this.args = matched_args;
|
||||
}
|
||||
name;
|
||||
targets;
|
||||
|
|
|
@ -16,7 +16,10 @@ export default function req(data, callback, errorCallback) {
|
|||
}
|
||||
|
||||
let client = new net.Socket();
|
||||
client.connect(port, hostname, () => {
|
||||
|
||||
let c_port = global.ctx.lights.port || port;
|
||||
let c_addr = global.ctx.lights.addr || hostname;
|
||||
client.connect(c_port, c_addr, () => {
|
||||
client.write(string_data);
|
||||
client.destroy();
|
||||
callback('success.');
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
dependencies:
|
||||
eris: 0.14.0
|
||||
socket.engine: 1.0.0
|
||||
lockfileVersion: 5.1
|
||||
lockfileVersion: 5.2
|
||||
packages:
|
||||
/eris/0.14.0:
|
||||
dependencies:
|
||||
|
@ -14,31 +13,11 @@ packages:
|
|||
tweetnacl: 1.0.3
|
||||
resolution:
|
||||
integrity: sha512-/W6X0SFR2swtA9oc4ga5Wh1TQcZtPgbUaDDdwYc67fvFUAtwC+V1xzWUZq2yDeJnTfB8Uot9SJWA8Lthe2sDtQ==
|
||||
/fs/0.0.1-security:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha1-invTcYa23d84E/I4WLV+yq9eQdQ=
|
||||
/ip/1.1.5:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=
|
||||
/net/1.0.2:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha1-0XV+yaf7I3HYPPR1XOPifhCCk4g=
|
||||
/opusscript/0.0.7:
|
||||
dev: false
|
||||
optional: true
|
||||
resolution:
|
||||
integrity: sha512-DcBadTdYTUuH9zQtepsLjQn4Ll6rs3dmeFvN+SD0ThPnxRBRm/WC1zXWPg+wgAJimB784gdZvUMA57gDP7FdVg==
|
||||
/socket.engine/1.0.0:
|
||||
dependencies:
|
||||
fs: 0.0.1-security
|
||||
ip: 1.1.5
|
||||
net: 1.0.2
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-vwc9JVBNe33686TBl9T3Ro53FaF09z11NVnrf0HIlYUOIDaZ1OFA1J1O6igU57qhP3NyUv4a+kZtgMm6SnziaQ==
|
||||
/tweetnacl/1.0.3:
|
||||
dev: false
|
||||
optional: true
|
||||
|
@ -60,4 +39,3 @@ packages:
|
|||
integrity: sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==
|
||||
specifiers:
|
||||
eris: ^0.14.0
|
||||
socket.engine: ^1.0.0
|
||||
|
|
Loading…
Reference in a new issue