|
@ -33,6 +33,7 @@ var supportedCaps = []string{ |
|
|
"chghost", |
|
|
"chghost", |
|
|
"account-tag", |
|
|
"account-tag", |
|
|
"echo-message", |
|
|
"echo-message", |
|
|
|
|
|
"draft/languages", |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ErrNoConnection is returned if you try to do something requiring a connection,
|
|
|
// ErrNoConnection is returned if you try to do something requiring a connection,
|
|
@ -158,6 +159,14 @@ func (client *Client) ISupport() *isupport.ISupport { |
|
|
return &client.isupport |
|
|
return &client.isupport |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// CapData returns if there was any additional CAP data for the given capability.
|
|
|
|
|
|
func (client *Client) CapData(cap string) string { |
|
|
|
|
|
client.mutex.RLock() |
|
|
|
|
|
defer client.mutex.RUnlock() |
|
|
|
|
|
|
|
|
|
|
|
return client.capData[cap] |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// CapEnabled returns whether an IRCv3 capability is enabled.
|
|
|
// CapEnabled returns whether an IRCv3 capability is enabled.
|
|
|
func (client *Client) CapEnabled(cap string) bool { |
|
|
func (client *Client) CapEnabled(cap string) bool { |
|
|
client.mutex.RLock() |
|
|
client.mutex.RLock() |
|
@ -911,9 +920,9 @@ func (client *Client) handleEvent(event *Event) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for i := range supportedCaps { |
|
|
for i := range supportedCaps { |
|
|
if supportedCaps[i] == token { |
|
|
|
|
|
|
|
|
if supportedCaps[i] == key { |
|
|
client.mutex.Lock() |
|
|
client.mutex.Lock() |
|
|
client.capsRequested = append(client.capsRequested, token) |
|
|
|
|
|
|
|
|
client.capsRequested = append(client.capsRequested, key) |
|
|
client.mutex.Unlock() |
|
|
client.mutex.Unlock() |
|
|
|
|
|
|
|
|
break |
|
|
break |
|
@ -945,10 +954,53 @@ func (client *Client) handleEvent(event *Event) { |
|
|
client.capEnabled[token] = true |
|
|
client.capEnabled[token] = true |
|
|
} |
|
|
} |
|
|
client.mutex.Unlock() |
|
|
client.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
// Special cases for supported tokens
|
|
|
|
|
|
switch token { |
|
|
|
|
|
case "draft/languages": |
|
|
|
|
|
{ |
|
|
|
|
|
if len(client.config.Languages) == 0 { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// draft/languages=15,en,~bs,~de,~el,~en-AU,~es,~fi,~fr-FR,~it,~no,~pl,~pt-BR,~ro,~tr-TR,~zh-CN
|
|
|
|
|
|
langData := strings.Split(client.capData[token], ",") |
|
|
|
|
|
if len(langData) < 0 { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
maxCount, err := strconv.Atoi(langData[0]) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
break |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
languages := make([]string, 0, maxCount) |
|
|
|
|
|
|
|
|
|
|
|
LanguageLoop: |
|
|
|
|
|
for _, lang := range client.config.Languages { |
|
|
|
|
|
for _, lang2 := range langData[1:] { |
|
|
|
|
|
if strings.HasPrefix(lang2, "~") { |
|
|
|
|
|
lang2 = lang2[1:] |
|
|
|
|
|
} |
|
|
|
|
|
if strings.EqualFold(lang, lang2) { |
|
|
|
|
|
languages = append(languages, lang) |
|
|
|
|
|
if len(languages) >= maxCount { |
|
|
|
|
|
break LanguageLoop |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if len(languages) > 0 { |
|
|
|
|
|
_ = client.Send("LANGUAGE " + strings.Join(languages, " ")) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if !client.Ready() { |
|
|
_ = client.Send("CAP END") |
|
|
_ = client.Send("CAP END") |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
case "NAK": |
|
|
case "NAK": |
|
|
{ |
|
|
{ |
|
|
// Remove offenders
|
|
|
// Remove offenders
|
|
|