Display prefixes in member list

Closes: https://todo.sr.ht/~emersion/gamja/43
This commit is contained in:
Drew DeVault
2021-05-28 11:45:27 -04:00
committed by Simon Ser
parent e90c07e64e
commit be1ecf607d
4 changed files with 171 additions and 4 deletions

View File

@@ -41,6 +41,7 @@ export const ERR_SASLABORTED = "906";
export const ERR_SASLALREADY = "907";
export const STD_CHANNEL_TYPES = "#&+!";
export const STD_CHANMODES = "beI,k,l,imnst";
const tagEscapeMap = {
";": "\\:",
@@ -510,3 +511,23 @@ export class CaseMapMap {
return this.entries();
}
}
export function parseMemberships(str) {
if (str[0] !== "(") {
throw new Error("malformed ISUPPORT PREFIX value: expected opening parenthesis");
}
var sep = str.indexOf(")");
if (sep < 0) {
throw new Error("malformed ISUPPORT PREFIX value: expected closing parenthesis");
}
var n = str.length - sep - 1;
var memberships = [];
for (var i = 0; i < n; i++) {
var mode = str[i + 1];
var prefix = str[sep + i + 1];
memberships.push({ mode, prefix });
}
return memberships;
}