Browse Source

bump irc-go to v0.1.0

tags/v2.10.0-rc1
Shivaram Lingamneni 2 years ago
parent
commit
74f3ea1d2e

+ 1
- 1
go.mod View File

@@ -8,7 +8,7 @@ require (
8 8
 	github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
9 9
 	github.com/ergochat/confusables v0.0.0-20201108231250-4ab98ab61fb1
10 10
 	github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775
11
-	github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce
11
+	github.com/ergochat/irc-go v0.1.0
12 12
 	github.com/go-sql-driver/mysql v1.6.0
13 13
 	github.com/go-test/deep v1.0.6 // indirect
14 14
 	github.com/golang-jwt/jwt v3.2.2+incompatible

+ 2
- 0
go.sum View File

@@ -12,6 +12,8 @@ github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775 h1:QSJIdpr3HOzJD
12 12
 github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775/go.mod h1:d2qvgjD0TvGNSvUs+mZgX090RiJlrzUYW6vtANGOy3A=
13 13
 github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce h1:RfyjeynouKZjmnN8WGzCSrtuHGZ9dwfSYBq405FPoqs=
14 14
 github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce/go.mod h1:2vi7KNpIPWnReB5hmLpl92eMywQvuIeIIGdt/FQCph0=
15
+github.com/ergochat/irc-go v0.1.0 h1:jBHUayERH9SiPOWe4ePDWRztBjIQsU/jwLbbGUuiOWM=
16
+github.com/ergochat/irc-go v0.1.0/go.mod h1:2vi7KNpIPWnReB5hmLpl92eMywQvuIeIIGdt/FQCph0=
15 17
 github.com/ergochat/scram v1.0.2-ergo1 h1:2bYXiRFQH636pT0msOG39fmEYl4Eq+OuutcyDsCix/g=
16 18
 github.com/ergochat/scram v1.0.2-ergo1/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs=
17 19
 github.com/ergochat/websocket v1.4.2-oragono1 h1:plMUunFBM6UoSCIYCKKclTdy/TkkHfUslhOfJQzfueM=

+ 2
- 1
vendor/github.com/ergochat/irc-go/LICENSE View File

@@ -1,4 +1,5 @@
1
-Copyright (c) 2016-2017 Daniel Oaks
1
+Copyright (c) 2016-2021 Daniel Oaks
2
+Copyright (c) 2018-2021 Shivaram Lingamneni
2 3
 
3 4
 Permission to use, copy, modify, and/or distribute this software for any
4 5
 purpose with or without fee is hereby granted, provided that the above

+ 27
- 11
vendor/github.com/ergochat/irc-go/ircmsg/message.go View File

@@ -65,7 +65,7 @@ var (
65 65
 // extended by the IRCv3 Message Tags specification with the introduction
66 66
 // of message tags.
67 67
 type Message struct {
68
-	Prefix         string
68
+	Source         string
69 69
 	Command        string
70 70
 	Params         []string
71 71
 	forceTrailing  bool
@@ -154,6 +154,22 @@ func (msg *Message) ClientOnlyTags() map[string]string {
154 154
 	return msg.clientOnlyTags
155 155
 }
156 156
 
157
+// Nick returns the name component of the message source (typically a nickname,
158
+// but possibly a server name).
159
+func (msg *Message) Nick() (nick string) {
160
+	nuh, err := ParseNUH(msg.Source)
161
+	if err == nil {
162
+		return nuh.Name
163
+	}
164
+	return
165
+}
166
+
167
+// NUH returns the source of the message as a parsed NUH ("nick-user-host");
168
+// if the source is not well-formed as a NUH, it returns an error.
169
+func (msg *Message) NUH() (nuh NUH, err error) {
170
+	return ParseNUH(msg.Source)
171
+}
172
+
157 173
 // ParseLine creates and returns a message from the given IRC line.
158 174
 func ParseLine(line string) (ircmsg Message, err error) {
159 175
 	return parseLine(line, 0, 0)
@@ -229,15 +245,15 @@ func parseLine(line string, maxTagDataLength int, truncateLen int) (ircmsg Messa
229 245
 	// by one or more ASCII SPACE characters"
230 246
 	line = trimInitialSpaces(line)
231 247
 
232
-	// prefix
248
+	// source
233 249
 	if 0 < len(line) && line[0] == ':' {
234
-		prefixEnd := strings.IndexByte(line, ' ')
235
-		if prefixEnd == -1 {
250
+		sourceEnd := strings.IndexByte(line, ' ')
251
+		if sourceEnd == -1 {
236 252
 			return ircmsg, ErrorLineIsEmpty
237 253
 		}
238
-		ircmsg.Prefix = line[1:prefixEnd]
239
-		// skip over the prefix and the separating space
240
-		line = line[prefixEnd+1:]
254
+		ircmsg.Source = line[1:sourceEnd]
255
+		// skip over the source and the separating space
256
+		line = line[sourceEnd+1:]
241 257
 	}
242 258
 
243 259
 	line = trimInitialSpaces(line)
@@ -312,8 +328,8 @@ func (ircmsg *Message) parseTags(tags string) (err error) {
312 328
 }
313 329
 
314 330
 // MakeMessage provides a simple way to create a new Message.
315
-func MakeMessage(tags map[string]string, prefix string, command string, params ...string) (ircmsg Message) {
316
-	ircmsg.Prefix = prefix
331
+func MakeMessage(tags map[string]string, source string, command string, params ...string) (ircmsg Message) {
332
+	ircmsg.Source = source
317 333
 	ircmsg.Command = command
318 334
 	ircmsg.Params = params
319 335
 	ircmsg.UpdateTags(tags)
@@ -411,9 +427,9 @@ func (ircmsg *Message) line(tagLimit, clientOnlyTagDataLimit, serverAddedTagData
411 427
 		return nil, ErrorTagsTooLong
412 428
 	}
413 429
 
414
-	if len(ircmsg.Prefix) > 0 {
430
+	if len(ircmsg.Source) > 0 {
415 431
 		buf.WriteByte(':')
416
-		buf.WriteString(ircmsg.Prefix)
432
+		buf.WriteString(ircmsg.Source)
417 433
 		buf.WriteByte(' ')
418 434
 	}
419 435
 

+ 61
- 0
vendor/github.com/ergochat/irc-go/ircmsg/userhost.go View File

@@ -0,0 +1,61 @@
1
+// written by Daniel Oaks <daniel@danieloaks.net>
2
+// released under the ISC license
3
+
4
+package ircmsg
5
+
6
+import (
7
+	"errors"
8
+	"strings"
9
+)
10
+
11
+var (
12
+	MalformedNUH = errors.New("NUH is malformed")
13
+)
14
+
15
+// NUH holds a parsed name!user@host source ("prefix") of an IRC message.
16
+// The Name member will be either a nickname (in the case of a user-initiated
17
+// message) or a server name (in the case of a server-initiated numeric,
18
+// command, or NOTICE).
19
+type NUH struct {
20
+	Name string
21
+	User string
22
+	Host string
23
+}
24
+
25
+// ParseNUH parses a NUH source of an IRC message into its constituent parts;
26
+// name (nickname or server name), username, and hostname.
27
+func ParseNUH(in string) (out NUH, err error) {
28
+	if len(in) == 0 {
29
+		return out, MalformedNUH
30
+	}
31
+
32
+	hostStart := strings.IndexByte(in, '@')
33
+	if hostStart != -1 {
34
+		out.Host = in[hostStart+1:]
35
+		in = in[:hostStart]
36
+	}
37
+	userStart := strings.IndexByte(in, '!')
38
+	if userStart != -1 {
39
+		out.User = in[userStart+1:]
40
+		in = in[:userStart]
41
+	}
42
+	out.Name = in
43
+
44
+	return
45
+}
46
+
47
+// Canonical returns the canonical string representation of the NUH.
48
+func (nuh *NUH) Canonical() (result string) {
49
+	var out strings.Builder
50
+	out.Grow(len(nuh.Name) + len(nuh.User) + len(nuh.Host) + 2)
51
+	out.WriteString(nuh.Name)
52
+	if len(nuh.User) != 0 {
53
+		out.WriteByte('!')
54
+		out.WriteString(nuh.User)
55
+	}
56
+	if len(nuh.Host) != 0 {
57
+		out.WriteByte('@')
58
+		out.WriteString(nuh.Host)
59
+	}
60
+	return out.String()
61
+}

+ 0
- 56
vendor/github.com/ergochat/irc-go/ircutils/userhost.go View File

@@ -1,56 +0,0 @@
1
-// written by Daniel Oaks <daniel@danieloaks.net>
2
-// released under the ISC license
3
-
4
-package ircutils
5
-
6
-import "strings"
7
-
8
-// UserHost holds a username+host combination
9
-type UserHost struct {
10
-	Nick string
11
-	User string
12
-	Host string
13
-}
14
-
15
-// ParseUserhost takes a userhost string and returns a UserHost instance.
16
-func ParseUserhost(userhost string) UserHost {
17
-	var uh UserHost
18
-
19
-	if len(userhost) == 0 {
20
-		return uh
21
-	}
22
-
23
-	if strings.Contains(userhost, "!") {
24
-		usersplit := strings.SplitN(userhost, "!", 2)
25
-		var rest string
26
-		if len(usersplit) == 2 {
27
-			uh.Nick = usersplit[0]
28
-			rest = usersplit[1]
29
-		} else {
30
-			rest = usersplit[0]
31
-		}
32
-
33
-		hostsplit := strings.SplitN(rest, "@", 2)
34
-		if len(hostsplit) == 2 {
35
-			uh.User = hostsplit[0]
36
-			uh.Host = hostsplit[1]
37
-		} else {
38
-			uh.User = hostsplit[0]
39
-		}
40
-	} else {
41
-		hostsplit := strings.SplitN(userhost, "@", 2)
42
-		if len(hostsplit) == 2 {
43
-			uh.Nick = hostsplit[0]
44
-			uh.Host = hostsplit[1]
45
-		} else {
46
-			uh.User = hostsplit[0]
47
-		}
48
-	}
49
-
50
-	return uh
51
-}
52
-
53
-// // Canonical returns the canonical string representation of the userhost.
54
-// func (uh *UserHost) Canonical() string {
55
-// 	return ""
56
-// }

+ 1
- 1
vendor/modules.txt View File

@@ -16,7 +16,7 @@ github.com/ergochat/confusables
16 16
 # github.com/ergochat/go-ident v0.0.0-20200511222032-830550b1d775
17 17
 ## explicit
18 18
 github.com/ergochat/go-ident
19
-# github.com/ergochat/irc-go v0.0.0-20210617222258-256f1601d3ce
19
+# github.com/ergochat/irc-go v0.1.0
20 20
 ## explicit; go 1.15
21 21
 github.com/ergochat/irc-go/ircfmt
22 22
 github.com/ergochat/irc-go/ircmsg

Loading…
Cancel
Save