Keep track of channel members, add /nick command

This commit is contained in:
Simon Ser 2020-06-10 19:51:54 +02:00
parent 9a3409e970
commit dba59fe2c7
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 58 additions and 2 deletions

View file

@ -1,5 +1,7 @@
const RPL_WELCOME = "001";
const RPL_TOPIC = "332";
const RPL_NAMREPLY = "353";
const RPL_ENDOFNAMES = "366";
const ERR_PASSWDMISMATCH = "464";
function parsePrefix(s) {
@ -106,3 +108,20 @@ function formatMessage(msg) {
s += "\r\n";
return s;
}
function parseMembership(s) {
// TODO: use the PREFIX token from RPL_ISUPPORT
const STD_MEMBERSHIPS = "~&@%+";
var i;
for (i = 0; i < s.length; i++) {
if (STD_MEMBERSHIPS.indexOf(s[i]) < 0) {
break;
}
}
return {
prefix: s.slice(0, i),
nick: s.slice(i),
};
}