Display prefixes in member list
Closes: https://todo.sr.ht/~emersion/gamja/43
This commit is contained in:
21
lib/irc.js
21
lib/irc.js
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user