Limit composer length
Often times IRC servers will truncate messages which are too big.
This commit is contained in:
30
lib/irc.js
30
lib/irc.js
@@ -479,6 +479,36 @@ export class Isupport {
|
||||
bot() {
|
||||
return this.raw.get("BOT");
|
||||
}
|
||||
|
||||
userLen() {
|
||||
if (!this.raw.has("USERLEN")) {
|
||||
return 20;
|
||||
}
|
||||
return parseInt(this.raw.get("USERLEN"), 10);
|
||||
}
|
||||
|
||||
hostLen() {
|
||||
if (!this.raw.has("HOSTLEN")) {
|
||||
return 63;
|
||||
}
|
||||
return parseInt(this.raw.get("HOSTLEN"), 10);
|
||||
}
|
||||
|
||||
lineLen() {
|
||||
if (!this.raw.has("LINELEN")) {
|
||||
return 512;
|
||||
}
|
||||
return parseInt(this.raw.get("LINELEN"), 10);
|
||||
}
|
||||
}
|
||||
|
||||
export function getMaxPrivmsgLen(isupport, nick, target) {
|
||||
let user = "_".repeat(isupport.userLen());
|
||||
let host = "_".repeat(isupport.hostLen());
|
||||
let prefix = { name: nick, user, host };
|
||||
let msg = { prefix, command: "PRIVMSG", params: [target, ""] };
|
||||
let raw = formatMessage(msg) + "\r\n";
|
||||
return isupport.lineLen() - raw.length;
|
||||
}
|
||||
|
||||
export const CaseMapping = {
|
||||
|
||||
Reference in New Issue
Block a user