Changeset 153 in code for trunk/upstream.go
- Timestamp:
- Mar 25, 2020, 10:16:53 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/upstream.go
r152 r153 50 50 channels map[string]*upstreamChannel 51 51 caps map[string]string 52 batches map[string]batch 52 53 53 54 tagsSupported bool … … 84 85 channels: make(map[string]*upstreamChannel), 85 86 caps: make(map[string]string), 87 batches: make(map[string]batch), 86 88 availableChannelTypes: stdChannelTypes, 87 89 availableChannelModes: stdChannelModes, … … 151 153 152 154 func (uc *upstreamConn) handleMessage(msg *irc.Message) error { 155 var msgBatch *batch 156 if batchName, ok := msg.GetTag("batch"); ok { 157 b, ok := uc.batches[batchName] 158 if !ok { 159 return fmt.Errorf("unexpected batch reference: batch was not defined: %q", batchName) 160 } 161 msgBatch = &b 162 } 163 153 164 switch msg.Command { 154 165 case "PING": … … 194 205 195 206 requestCaps := make([]string, 0, 16) 196 for _, c := range []string{"message-tags" } {207 for _, c := range []string{"message-tags", "batch"} { 197 208 if _, ok := uc.caps[c]; ok { 198 209 requestCaps = append(requestCaps, c) … … 406 417 } 407 418 } 419 case "BATCH": 420 var tag string 421 if err := parseMessageParams(msg, &tag); err != nil { 422 return err 423 } 424 425 if strings.HasPrefix(tag, "+") { 426 tag = tag[1:] 427 if _, ok := uc.batches[tag]; ok { 428 return fmt.Errorf("unexpected BATCH reference tag: batch was already defined: %q", tag) 429 } 430 var batchType string 431 if err := parseMessageParams(msg, nil, &batchType); err != nil { 432 return err 433 } 434 uc.batches[tag] = batch{ 435 Type: batchType, 436 Params: msg.Params[2:], 437 Outer: msgBatch, 438 } 439 } else if strings.HasPrefix(tag, "-") { 440 tag = tag[1:] 441 if _, ok := uc.batches[tag]; !ok { 442 return fmt.Errorf("unknown BATCH reference tag: %q", tag) 443 } 444 delete(uc.batches, tag) 445 } else { 446 return fmt.Errorf("unexpected BATCH reference tag: missing +/- prefix: %q", tag) 447 } 408 448 case "NICK": 409 449 if msg.Prefix == nil {
Note:
See TracChangeset
for help on using the changeset viewer.