parse $OpList, set IsOperator bool in UserInfo structs

This commit is contained in:
mappu 2016-05-08 12:49:36 +12:00
parent 861090b0e9
commit df0211c67d
2 changed files with 28 additions and 2 deletions

View File

@ -187,6 +187,33 @@ func (this *HubConnection) processProtocolMessage(message string) {
} }
} }
case "$OpList":
oplist := strings.Split(commandParts[1], "$$")
opmap := map[string]struct{}{}
// Organise/sort the list, and ensure we're not meeting an operator for
// the first time
for _, nick := range oplist {
if len(nick) > 0 {
opmap[nick] = struct{}{}
this.userJoined_NameOnly(nick) // assert existence; noop otherwise
}
}
// Mark all mentioned nicks as being operators, and all unmentioned nicks
// as being /not/ an operator. (second pass minimises RW mutex use)
func() {
this.userLock.Lock()
defer this.userLock.Unlock()
for nick, userinfo := range this.users {
_, isop := opmap[nick]
userinfo.IsOperator = isop
this.users[nick] = userinfo
}
}()
case "$To:": case "$To:":
valid := false valid := false
if rx_incomingTo.MatchString(commandParts[1]) { if rx_incomingTo.MatchString(commandParts[1]) {
@ -216,8 +243,6 @@ func (this *HubConnection) processProtocolMessage(message string) {
// IGNORABLE COMMANDS // IGNORABLE COMMANDS
case "$Supports": case "$Supports":
case "$UserCommand": // TODO $UserCommand 1 1 Group chat\New group chat$<%[mynick]> !groupchat_new&#124;| case "$UserCommand": // TODO $UserCommand 1 1 Group chat\New group chat$<%[mynick]> !groupchat_new&#124;|
case "$UserList":
case "$OpList":
case "$HubTopic": case "$HubTopic":
case "$Search": case "$Search":
case "$ConnectToMe": case "$ConnectToMe":

View File

@ -46,6 +46,7 @@ type UserInfo struct {
HubsUnregistered uint64 HubsUnregistered uint64
HubsRegistered uint64 HubsRegistered uint64
HubsOperator uint64 HubsOperator uint64
IsOperator bool
} }
var rx_myinfo *regexp.Regexp var rx_myinfo *regexp.Regexp