modified: src/clients/irc.mjs

This commit is contained in:
Flummi 2019-08-21 15:28:07 +00:00
parent 267d8cf798
commit cabe2dc1d5

View File

@ -83,7 +83,7 @@ export default class irc extends EventEmitter {
this.socket.write(`${data}\n`); this.socket.write(`${data}\n`);
} }
sendmsg(mode, recipient, msg) { sendmsg(mode, recipient, msg) {
msg = msg.split(/\r?\n/); msg = Array.isArray(msg) ? msg : msg.split(/\r?\n/);
if (msg.length > 6) if (msg.length > 6)
return this.emit("data", ["error", "too many lines"]); return this.emit("data", ["error", "too many lines"]);
msg.forEach(e => this.send( msgmodes[mode].replace("{recipient}", recipient).replace("{msg}", e) )); msg.forEach(e => this.send( msgmodes[mode].replace("{recipient}", recipient).replace("{msg}", e) ));
@ -111,7 +111,7 @@ export default class irc extends EventEmitter {
message: tmp.params[1].replace(/\u0002/, ""), message: tmp.params[1].replace(/\u0002/, ""),
time: ~~(Date.now() / 1000), time: ~~(Date.now() / 1000),
raw: tmp, raw: tmp,
reply: msg => this.sendmsg("normal", tmp.params[0], this.format(""+msg)), reply: msg => this.sendmsg("normal", tmp.params[0], msg),
replyAction: msg => this.sendmsg("action", tmp.params[0], this.format(""+msg)), replyAction: msg => this.sendmsg("action", tmp.params[0], this.format(""+msg)),
replyNotice: msg => this.sendmsg("notice", tmp.params[0], this.format(""+msg)), replyNotice: msg => this.sendmsg("notice", tmp.params[0], this.format(""+msg)),
self: this.server, self: this.server,