mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
review fix
This commit is contained in:
parent
2a33c1483b
commit
a1bbe0c7f2
@ -15,12 +15,6 @@ from collections import namedtuple
|
|||||||
CapDef = namedtuple("CapDef", ['identifier', 'name', 'url', 'standard'])
|
CapDef = namedtuple("CapDef", ['identifier', 'name', 'url', 'standard'])
|
||||||
|
|
||||||
CAPDEFS = [
|
CAPDEFS = [
|
||||||
CapDef(
|
|
||||||
identifier="LabelTagName",
|
|
||||||
name="draft/label",
|
|
||||||
url="https://ircv3.net/specs/extensions/labeled-response.html",
|
|
||||||
standard="draft IRCv3 tag name",
|
|
||||||
),
|
|
||||||
CapDef(
|
CapDef(
|
||||||
identifier="AccountNotify",
|
identifier="AccountNotify",
|
||||||
name="account-notify",
|
name="account-notify",
|
||||||
@ -188,11 +182,13 @@ const (
|
|||||||
print(file=output)
|
print(file=output)
|
||||||
print(")", file=output)
|
print(")", file=output)
|
||||||
|
|
||||||
|
print("// `capabilityNames[capab]` is the string name of the capability `capab`", file=output)
|
||||||
print("""var ( capabilityNames = [numCapabs]string{""", file=output)
|
print("""var ( capabilityNames = [numCapabs]string{""", file=output)
|
||||||
for capdef in CAPDEFS:
|
for capdef in CAPDEFS:
|
||||||
print("\"%s\"," % (capdef.name,), file=output)
|
print("\"%s\"," % (capdef.name,), file=output)
|
||||||
print("})", file=output)
|
print("})", file=output)
|
||||||
|
|
||||||
|
# run the generated code through `gofmt -s`, which will print it to stdout
|
||||||
gofmt = subprocess.Popen(['gofmt', '-s'], stdin=subprocess.PIPE)
|
gofmt = subprocess.Popen(['gofmt', '-s'], stdin=subprocess.PIPE)
|
||||||
gofmt.communicate(input=output.getvalue().encode('utf-8'))
|
gofmt.communicate(input=output.getvalue().encode('utf-8'))
|
||||||
if gofmt.poll() != 0:
|
if gofmt.poll() != 0:
|
||||||
|
@ -51,6 +51,12 @@ const (
|
|||||||
NegotiatedState State = iota
|
NegotiatedState State = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// LabelTagName is the tag name used for the labeled-response spec.
|
||||||
|
// https://ircv3.net/specs/extensions/labeled-response.html
|
||||||
|
LabelTagName = "draft/label"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
nameToCapability = make(map[string]Capability)
|
nameToCapability = make(map[string]Capability)
|
||||||
for capab, name := range capabilityNames {
|
for capab, name := range capabilityNames {
|
||||||
|
@ -7,16 +7,12 @@ package caps
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// number of recognized capabilities:
|
// number of recognized capabilities:
|
||||||
numCapabs = 21
|
numCapabs = 20
|
||||||
// length of the uint64 array that represents the bitset:
|
// length of the uint64 array that represents the bitset:
|
||||||
bitsetLen = 1
|
bitsetLen = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// LabelTagName is the draft IRCv3 tag name capability named "draft/label":
|
|
||||||
// https://ircv3.net/specs/extensions/labeled-response.html
|
|
||||||
LabelTagName Capability = iota
|
|
||||||
|
|
||||||
// AccountNotify is the IRCv3 capability named "account-notify":
|
// AccountNotify is the IRCv3 capability named "account-notify":
|
||||||
// https://ircv3.net/specs/extensions/account-notify-3.1.html
|
// https://ircv3.net/specs/extensions/account-notify-3.1.html
|
||||||
AccountNotify Capability = iota
|
AccountNotify Capability = iota
|
||||||
@ -98,9 +94,9 @@ const (
|
|||||||
UserhostInNames Capability = iota
|
UserhostInNames Capability = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// `capabilityNames[capab]` is the string name of the capability `capab`
|
||||||
var (
|
var (
|
||||||
capabilityNames = [numCapabs]string{
|
capabilityNames = [numCapabs]string{
|
||||||
"draft/label",
|
|
||||||
"account-notify",
|
"account-notify",
|
||||||
"account-tag",
|
"account-tag",
|
||||||
"away-notify",
|
"away-notify",
|
||||||
|
@ -23,7 +23,7 @@ type ResponseBuffer struct {
|
|||||||
|
|
||||||
// GetLabel returns the label from the given message.
|
// GetLabel returns the label from the given message.
|
||||||
func GetLabel(msg ircmsg.IrcMessage) string {
|
func GetLabel(msg ircmsg.IrcMessage) string {
|
||||||
return msg.Tags[caps.LabelTagName.Name()].Value
|
return msg.Tags[caps.LabelTagName].Value
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewResponseBuffer returns a new ResponseBuffer.
|
// NewResponseBuffer returns a new ResponseBuffer.
|
||||||
@ -90,13 +90,13 @@ func (rb *ResponseBuffer) Send() error {
|
|||||||
// if label but no batch, add label to first message
|
// if label but no batch, add label to first message
|
||||||
if useLabel && batch == nil {
|
if useLabel && batch == nil {
|
||||||
message := rb.messages[0]
|
message := rb.messages[0]
|
||||||
message.Tags[caps.LabelTagName.Name()] = ircmsg.MakeTagValue(rb.Label)
|
message.Tags[caps.LabelTagName] = ircmsg.MakeTagValue(rb.Label)
|
||||||
rb.messages[0] = message
|
rb.messages[0] = message
|
||||||
}
|
}
|
||||||
|
|
||||||
// start batch if required
|
// start batch if required
|
||||||
if batch != nil {
|
if batch != nil {
|
||||||
batch.Start(rb.target, ircmsg.MakeTags(caps.LabelTagName.Name(), rb.Label))
|
batch.Start(rb.target, ircmsg.MakeTags(caps.LabelTagName, rb.Label))
|
||||||
}
|
}
|
||||||
|
|
||||||
// send each message out
|
// send each message out
|
||||||
|
Loading…
Reference in New Issue
Block a user