Browse Source

review fix

tags/v0.12.0
Shivaram Lingamneni 6 years ago
parent
commit
a1bbe0c7f2
4 changed files with 13 additions and 15 deletions
  1. 2
    6
      gencapdefs.py
  2. 6
    0
      irc/caps/constants.go
  3. 2
    6
      irc/caps/defs.go
  4. 3
    3
      irc/responsebuffer.go

+ 2
- 6
gencapdefs.py View File

@@ -15,12 +15,6 @@ from collections import namedtuple
15 15
 CapDef = namedtuple("CapDef", ['identifier', 'name', 'url', 'standard'])
16 16
 
17 17
 CAPDEFS = [
18
-    CapDef(
19
-        identifier="LabelTagName",
20
-        name="draft/label",
21
-        url="https://ircv3.net/specs/extensions/labeled-response.html",
22
-        standard="draft IRCv3 tag name",
23
-    ),
24 18
     CapDef(
25 19
         identifier="AccountNotify",
26 20
         name="account-notify",
@@ -188,11 +182,13 @@ const (
188 182
         print(file=output)
189 183
     print(")", file=output)
190 184
 
185
+    print("// `capabilityNames[capab]` is the string name of the capability `capab`", file=output)
191 186
     print("""var ( capabilityNames = [numCapabs]string{""", file=output)
192 187
     for capdef in CAPDEFS:
193 188
         print("\"%s\"," % (capdef.name,), file=output)
194 189
     print("})", file=output)
195 190
 
191
+    # run the generated code through `gofmt -s`, which will print it to stdout
196 192
     gofmt = subprocess.Popen(['gofmt', '-s'], stdin=subprocess.PIPE)
197 193
     gofmt.communicate(input=output.getvalue().encode('utf-8'))
198 194
     if gofmt.poll() != 0:

+ 6
- 0
irc/caps/constants.go View File

@@ -51,6 +51,12 @@ const (
51 51
 	NegotiatedState State = iota
52 52
 )
53 53
 
54
+const (
55
+	// LabelTagName is the tag name used for the labeled-response spec.
56
+	// https://ircv3.net/specs/extensions/labeled-response.html
57
+	LabelTagName = "draft/label"
58
+)
59
+
54 60
 func init() {
55 61
 	nameToCapability = make(map[string]Capability)
56 62
 	for capab, name := range capabilityNames {

+ 2
- 6
irc/caps/defs.go View File

@@ -7,16 +7,12 @@ package caps
7 7
 
8 8
 const (
9 9
 	// number of recognized capabilities:
10
-	numCapabs = 21
10
+	numCapabs = 20
11 11
 	// length of the uint64 array that represents the bitset:
12 12
 	bitsetLen = 1
13 13
 )
14 14
 
15 15
 const (
16
-	// LabelTagName is the draft IRCv3 tag name capability named "draft/label":
17
-	// https://ircv3.net/specs/extensions/labeled-response.html
18
-	LabelTagName Capability = iota
19
-
20 16
 	// AccountNotify is the IRCv3 capability named "account-notify":
21 17
 	// https://ircv3.net/specs/extensions/account-notify-3.1.html
22 18
 	AccountNotify Capability = iota
@@ -98,9 +94,9 @@ const (
98 94
 	UserhostInNames Capability = iota
99 95
 )
100 96
 
97
+// `capabilityNames[capab]` is the string name of the capability `capab`
101 98
 var (
102 99
 	capabilityNames = [numCapabs]string{
103
-		"draft/label",
104 100
 		"account-notify",
105 101
 		"account-tag",
106 102
 		"away-notify",

+ 3
- 3
irc/responsebuffer.go View File

@@ -23,7 +23,7 @@ type ResponseBuffer struct {
23 23
 
24 24
 // GetLabel returns the label from the given message.
25 25
 func GetLabel(msg ircmsg.IrcMessage) string {
26
-	return msg.Tags[caps.LabelTagName.Name()].Value
26
+	return msg.Tags[caps.LabelTagName].Value
27 27
 }
28 28
 
29 29
 // NewResponseBuffer returns a new ResponseBuffer.
@@ -90,13 +90,13 @@ func (rb *ResponseBuffer) Send() error {
90 90
 	// if label but no batch, add label to first message
91 91
 	if useLabel && batch == nil {
92 92
 		message := rb.messages[0]
93
-		message.Tags[caps.LabelTagName.Name()] = ircmsg.MakeTagValue(rb.Label)
93
+		message.Tags[caps.LabelTagName] = ircmsg.MakeTagValue(rb.Label)
94 94
 		rb.messages[0] = message
95 95
 	}
96 96
 
97 97
 	// start batch if required
98 98
 	if batch != nil {
99
-		batch.Start(rb.target, ircmsg.MakeTags(caps.LabelTagName.Name(), rb.Label))
99
+		batch.Start(rb.target, ircmsg.MakeTags(caps.LabelTagName, rb.Label))
100 100
 	}
101 101
 
102 102
 	// send each message out

Loading…
Cancel
Save