summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/lrstanley/girc
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/lrstanley/girc')
-rw-r--r--vendor/github.com/lrstanley/girc/.travis.yml7
-rw-r--r--vendor/github.com/lrstanley/girc/commands.go4
-rw-r--r--vendor/github.com/lrstanley/girc/constants.go1
-rw-r--r--vendor/github.com/lrstanley/girc/ctcp.go27
-rw-r--r--vendor/github.com/lrstanley/girc/event.go26
-rw-r--r--vendor/github.com/lrstanley/girc/format.go2
-rw-r--r--vendor/github.com/lrstanley/girc/go.mod1
-rw-r--r--vendor/github.com/lrstanley/girc/handler.go2
8 files changed, 44 insertions, 26 deletions
diff --git a/vendor/github.com/lrstanley/girc/.travis.yml b/vendor/github.com/lrstanley/girc/.travis.yml
index 658e65d9..96a1bb8a 100644
--- a/vendor/github.com/lrstanley/girc/.travis.yml
+++ b/vendor/github.com/lrstanley/girc/.travis.yml
@@ -1,14 +1,13 @@
language: go
go:
-- 1.8
-- 1.9
+- 1.11.x
- tip
before_install:
-- go get -v github.com/golang/lint/golint
+- go get -v golang.org/x/lint/golint
script:
- $HOME/gopath/bin/golint -min_confidence 0.9 -set_exit_status
- GORACE="exitcode=1 halt_on_error=1" go test -v -coverprofile=coverage.txt -race -timeout 3m -count 3 -cpu 1,4
-- go tool vet -v -all .
+- go vet -v .
after_success:
- bash <(curl -s https://codecov.io/bash)
branches:
diff --git a/vendor/github.com/lrstanley/girc/commands.go b/vendor/github.com/lrstanley/girc/commands.go
index d22f7616..300db9ed 100644
--- a/vendor/github.com/lrstanley/girc/commands.go
+++ b/vendor/github.com/lrstanley/girc/commands.go
@@ -70,7 +70,7 @@ func (cmd *Commands) PartMessage(channel, message string) {
// PRIVMSG specifically. ctcpType is the CTCP command, e.g. "FINGER", "TIME",
// "VERSION", etc.
func (cmd *Commands) SendCTCP(target, ctcpType, message string) {
- out := encodeCTCPRaw(ctcpType, message)
+ out := EncodeCTCPRaw(ctcpType, message)
if out == "" {
panic(fmt.Sprintf("invalid CTCP: %s -> %s: %s", target, ctcpType, message))
}
@@ -95,7 +95,7 @@ func (cmd *Commands) SendCTCPReplyf(target, ctcpType, format string, a ...interf
// SendCTCPReply sends a CTCP response to target. Note that this method uses
// NOTICE specifically.
func (cmd *Commands) SendCTCPReply(target, ctcpType, message string) {
- out := encodeCTCPRaw(ctcpType, message)
+ out := EncodeCTCPRaw(ctcpType, message)
if out == "" {
panic(fmt.Sprintf("invalid CTCP: %s -> %s: %s", target, ctcpType, message))
}
diff --git a/vendor/github.com/lrstanley/girc/constants.go b/vendor/github.com/lrstanley/girc/constants.go
index 4d3c65bc..76ba482d 100644
--- a/vendor/github.com/lrstanley/girc/constants.go
+++ b/vendor/github.com/lrstanley/girc/constants.go
@@ -6,6 +6,7 @@ package girc
// Standard CTCP based constants.
const (
+ CTCP_ACTION = "ACTION"
CTCP_PING = "PING"
CTCP_PONG = "PONG"
CTCP_VERSION = "VERSION"
diff --git a/vendor/github.com/lrstanley/girc/ctcp.go b/vendor/github.com/lrstanley/girc/ctcp.go
index 6076ab10..45fc6be5 100644
--- a/vendor/github.com/lrstanley/girc/ctcp.go
+++ b/vendor/github.com/lrstanley/girc/ctcp.go
@@ -30,18 +30,22 @@ type CTCPEvent struct {
Reply bool `json:"reply"`
}
-// decodeCTCP decodes an incoming CTCP event, if it is CTCP. nil is returned
-// if the incoming event does not match a valid CTCP.
-func decodeCTCP(e *Event) *CTCPEvent {
+// DecodeCTCP decodes an incoming CTCP event, if it is CTCP. nil is returned
+// if the incoming event does not have valid CTCP encoding.
+func DecodeCTCP(e *Event) *CTCPEvent {
// http://www.irchelp.org/protocol/ctcpspec.html
+ if e == nil {
+ return nil
+ }
+
// Must be targeting a user/channel, AND trailing must have
// DELIM+TAG+DELIM minimum (at least 3 chars).
if len(e.Params) != 1 || len(e.Trailing) < 3 {
return nil
}
- if (e.Command != PRIVMSG && e.Command != NOTICE) || !IsValidNick(e.Params[0]) {
+ if e.Command != PRIVMSG && e.Command != NOTICE {
return nil
}
@@ -88,18 +92,18 @@ func decodeCTCP(e *Event) *CTCPEvent {
}
}
-// encodeCTCP encodes a CTCP event into a string, including delimiters.
-func encodeCTCP(ctcp *CTCPEvent) (out string) {
+// EncodeCTCP encodes a CTCP event into a string, including delimiters.
+func EncodeCTCP(ctcp *CTCPEvent) (out string) {
if ctcp == nil {
return ""
}
- return encodeCTCPRaw(ctcp.Command, ctcp.Text)
+ return EncodeCTCPRaw(ctcp.Command, ctcp.Text)
}
-// encodeCTCPRaw is much like encodeCTCP, however accepts a raw command and
+// EncodeCTCPRaw is much like EncodeCTCP, however accepts a raw command and
// string as input.
-func encodeCTCPRaw(cmd, text string) (out string) {
+func EncodeCTCPRaw(cmd, text string) (out string) {
if len(cmd) <= 0 {
return ""
}
@@ -145,6 +149,11 @@ func (c *CTCP) call(client *Client, event *CTCPEvent) {
}
if _, ok := c.handlers[event.Command]; !ok {
+ // If ACTION, don't do anything.
+ if event.Command == CTCP_ACTION {
+ return
+ }
+
// Send a ERRMSG reply, if we know who sent it.
if event.Source != nil && IsValidNick(event.Source.Name) {
client.Cmd.SendCTCPReply(event.Source.Name, CTCP_ERRMSG, "that is an unknown CTCP query")
diff --git a/vendor/github.com/lrstanley/girc/event.go b/vendor/github.com/lrstanley/girc/event.go
index 5e17b15b..0b40b40b 100644
--- a/vendor/github.com/lrstanley/girc/event.go
+++ b/vendor/github.com/lrstanley/girc/event.go
@@ -355,11 +355,15 @@ func (e *Event) Pretty() (out string, ok bool) {
}
if (e.Command == PRIVMSG || e.Command == NOTICE) && len(e.Params) > 0 {
- if ctcp := decodeCTCP(e); ctcp != nil {
+ if ctcp := DecodeCTCP(e); ctcp != nil {
if ctcp.Reply {
return
}
+ if ctcp.Command == CTCP_ACTION {
+ return fmt.Sprintf("[%s] **%s** %s", strings.Join(e.Params, ","), ctcp.Source.Name, ctcp.Text), true
+ }
+
return fmt.Sprintf("[*] CTCP query from %s: %s%s", ctcp.Source.Name, ctcp.Command, " "+ctcp.Text), true
}
return fmt.Sprintf("[%s] (%s) %s", strings.Join(e.Params, ","), e.Source.Name, e.Trailing), true
@@ -448,23 +452,27 @@ func (e *Event) Pretty() (out string, ok bool) {
return "", false
}
-// IsAction checks to see if the event is a PRIVMSG, and is an ACTION (/me).
+// IsAction checks to see if the event is an ACTION (/me).
func (e *Event) IsAction() bool {
- if e.Source == nil || e.Command != PRIVMSG || len(e.Trailing) < 9 {
+ if e.Command != PRIVMSG {
return false
}
- if !strings.HasPrefix(e.Trailing, "\001ACTION") || e.Trailing[len(e.Trailing)-1] != ctcpDelim {
- return false
- }
+ ok, ctcp := e.IsCTCP()
+ return ok && ctcp.Command == CTCP_ACTION
+}
- return true
+// IsCTCP checks to see if the event is a CTCP event, and if so, returns the
+// converted CTCP event.
+func (e *Event) IsCTCP() (ok bool, ctcp *CTCPEvent) {
+ ctcp = DecodeCTCP(e)
+ return ctcp != nil, ctcp
}
// IsFromChannel checks to see if a message was from a channel (rather than
// a private message).
func (e *Event) IsFromChannel() bool {
- if e.Source == nil || e.Command != PRIVMSG || len(e.Params) < 1 {
+ if e.Source == nil || (e.Command != PRIVMSG && e.Command != NOTICE) || len(e.Params) < 1 {
return false
}
@@ -478,7 +486,7 @@ func (e *Event) IsFromChannel() bool {
// IsFromUser checks to see if a message was from a user (rather than a
// channel).
func (e *Event) IsFromUser() bool {
- if e.Source == nil || e.Command != PRIVMSG || len(e.Params) < 1 {
+ if e.Source == nil || (e.Command != PRIVMSG && e.Command != NOTICE) || len(e.Params) < 1 {
return false
}
diff --git a/vendor/github.com/lrstanley/girc/format.go b/vendor/github.com/lrstanley/girc/format.go
index b974c3bd..762f602b 100644
--- a/vendor/github.com/lrstanley/girc/format.go
+++ b/vendor/github.com/lrstanley/girc/format.go
@@ -113,7 +113,7 @@ func Fmt(text string) string {
if last > -1 {
// A-Z, a-z, and ","
- if text[i] != ',' && (text[i] <= 'A' || text[i] >= 'Z') && (text[i] <= 'a' || text[i] >= 'z') {
+ if text[i] != ',' && (text[i] < 'A' || text[i] > 'Z') && (text[i] < 'a' || text[i] > 'z') {
last = -1
continue
}
diff --git a/vendor/github.com/lrstanley/girc/go.mod b/vendor/github.com/lrstanley/girc/go.mod
new file mode 100644
index 00000000..57b39ae8
--- /dev/null
+++ b/vendor/github.com/lrstanley/girc/go.mod
@@ -0,0 +1 @@
+module github.com/lrstanley/girc
diff --git a/vendor/github.com/lrstanley/girc/handler.go b/vendor/github.com/lrstanley/girc/handler.go
index bde08976..ec717de6 100644
--- a/vendor/github.com/lrstanley/girc/handler.go
+++ b/vendor/github.com/lrstanley/girc/handler.go
@@ -46,7 +46,7 @@ func (c *Client) RunHandlers(event *Event) {
}
// Check if it's a CTCP.
- if ctcp := decodeCTCP(event.Copy()); ctcp != nil {
+ if ctcp := DecodeCTCP(event.Copy()); ctcp != nil {
// Execute it.
c.CTCP.call(c, ctcp)
}