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
 CapDef = namedtuple("CapDef", ['identifier', 'name', 'url', 'standard'])
15
 CapDef = namedtuple("CapDef", ['identifier', 'name', 'url', 'standard'])
16
 
16
 
17
 CAPDEFS = [
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
     CapDef(
18
     CapDef(
25
         identifier="AccountNotify",
19
         identifier="AccountNotify",
26
         name="account-notify",
20
         name="account-notify",
188
         print(file=output)
182
         print(file=output)
189
     print(")", file=output)
183
     print(")", file=output)
190
 
184
 
185
+    print("// `capabilityNames[capab]` is the string name of the capability `capab`", file=output)
191
     print("""var ( capabilityNames = [numCapabs]string{""", file=output)
186
     print("""var ( capabilityNames = [numCapabs]string{""", file=output)
192
     for capdef in CAPDEFS:
187
     for capdef in CAPDEFS:
193
         print("\"%s\"," % (capdef.name,), file=output)
188
         print("\"%s\"," % (capdef.name,), file=output)
194
     print("})", file=output)
189
     print("})", file=output)
195
 
190
 
191
+    # run the generated code through `gofmt -s`, which will print it to stdout
196
     gofmt = subprocess.Popen(['gofmt', '-s'], stdin=subprocess.PIPE)
192
     gofmt = subprocess.Popen(['gofmt', '-s'], stdin=subprocess.PIPE)
197
     gofmt.communicate(input=output.getvalue().encode('utf-8'))
193
     gofmt.communicate(input=output.getvalue().encode('utf-8'))
198
     if gofmt.poll() != 0:
194
     if gofmt.poll() != 0:

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

51
 	NegotiatedState State = iota
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
 func init() {
60
 func init() {
55
 	nameToCapability = make(map[string]Capability)
61
 	nameToCapability = make(map[string]Capability)
56
 	for capab, name := range capabilityNames {
62
 	for capab, name := range capabilityNames {

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

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

+ 3
- 3
irc/responsebuffer.go View File

23
 
23
 
24
 // GetLabel returns the label from the given message.
24
 // GetLabel returns the label from the given message.
25
 func GetLabel(msg ircmsg.IrcMessage) string {
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
 // NewResponseBuffer returns a new ResponseBuffer.
29
 // NewResponseBuffer returns a new ResponseBuffer.
90
 	// if label but no batch, add label to first message
90
 	// if label but no batch, add label to first message
91
 	if useLabel && batch == nil {
91
 	if useLabel && batch == nil {
92
 		message := rb.messages[0]
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
 		rb.messages[0] = message
94
 		rb.messages[0] = message
95
 	}
95
 	}
96
 
96
 
97
 	// start batch if required
97
 	// start batch if required
98
 	if batch != nil {
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
 	// send each message out
102
 	// send each message out

Loading…
Cancel
Save