New Upstream Release - golang-sorcix-irc-dev
Ready changes
Summary
Merged new upstream version: 1.1.4 (was: 1.1.0).
Resulting package
Built on 2023-01-12T06:31 (took 2m6s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases golang-sorcix-irc-dev
Diff
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..9ef1ad0
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,17 @@
+language: go
+go_import_path: gopkg.in/sorcix/irc.v1
+go:
+ - 1.0
+ - 1.1
+ - 1.2
+ - 1.3
+ - 1.4
+ - 1.5
+ - 1.6
+ - tip
+script:
+ - go test -v -bench=.
+matrix:
+ allow_failures:
+ - go: 1.0
+ - go: 1.1
diff --git a/README.md b/README.md
index dad2d9b..8e36c44 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# Go **irc** package
-[Package Documentation][Documentation] @ godoc.org
+Please use the [**v2** branch][v2] for new projects!
-[![Build Status](https://drone.io/github.com/sorcix/irc/status.png)](https://drone.io/github.com/sorcix/irc/latest)
+[![GoDoc](https://godoc.org/gopkg.in/sorcix/irc.v1?status.svg)](https://godoc.org/gopkg.in/sorcix/irc.v1)
## Features
Package irc allows your application to speak the IRC protocol.
@@ -14,59 +14,9 @@ Package irc allows your application to speak the IRC protocol.
*This package does not manage your entire IRC connection. It only translates the protocol to easy to use Go types. It is meant as a single component in a larger IRC library, or for basic IRC bots for which a large IRC package would be overkill.*
-### Message
-The [Message][] and [Prefix][] types provide translation to and from IRC message format.
+## Usage
- // Parse the IRC-encoded data and stores the result in a new struct.
- message := irc.ParseMessage(raw)
+Please use the [**v2** branch][v2] for new projects!
- // Returns the IRC encoding of the message.
- raw = message.String()
-
-### Encoder & Decoder
-The [Encoder][] and [Decoder][] types allow working with IRC message streams.
-
- // Create a decoder that reads from given io.Reader
- dec := irc.NewDecoder(reader)
-
- // Decode the next IRC message
- message, err := dec.Decode()
-
- // Create an encoder that writes to given io.Writer
- enc := irc.NewEncoder(writer)
-
- // Send a message to the writer.
- enc.Encode(message)
-
-### Conn
-The [Conn][] type combines an [Encoder][] and [Decoder][] for a duplex connection.
-
- c, err := irc.Dial("irc.server.net:6667")
-
- // Methods from both Encoder and Decoder are available
- message, err := c.Decode()
-
-## Examples
-Check these other projects for an example on how to use the package:
-
-Clients:
-
- - https://github.com/nickvanw/ircx (great simple example)
- - https://github.com/FSX/jun
- - https://github.com/jnwhiteh/wallops
- - https://github.com/Alligator/gomero
- - https://github.com/msparks/iq
- - https://github.com/TheCreeper/HackBot
-
-Servers:
-
- - https://github.com/nightexcessive/excessiveircd
-
-
-[Documentation]: https://godoc.org/github.com/sorcix/irc "Package documentation by Godoc.org"
-[Message]: https://godoc.org/github.com/sorcix/irc#Message "Message type documentation"
-[Prefix]: https://godoc.org/github.com/sorcix/irc#Prefix "Prefix type documentation"
-[Encoder]: https://godoc.org/github.com/sorcix/irc#Encoder "Encoder type documentation"
-[Decoder]: https://godoc.org/github.com/sorcix/irc#Decoder "Decoder type documentation"
-[Conn]: https://godoc.org/github.com/sorcix/irc#Conn "Conn type documentation"
-[RFC1459]: https://tools.ietf.org/html/rfc1459.html "RFC 1459"
+[Documentation]: https://godoc.org/gopkg.in/sorcix/irc.v1 "Package documentation by Godoc.org"
+[v2]: https://github.com/sorcix/irc/tree/v2
diff --git a/constants.go b/constants.go
index b93aa47..d4812ba 100644
--- a/constants.go
+++ b/constants.go
@@ -99,6 +99,7 @@ const (
RPL_CREATED = "003"
RPL_MYINFO = "004"
RPL_BOUNCE = "005"
+ RPL_ISUPPORT = "005"
RPL_USERHOST = "302"
RPL_ISON = "303"
RPL_AWAY = "301"
@@ -259,3 +260,39 @@ const (
ERR_SASLALREADY = "907"
RPL_SASLMECHS = "908"
)
+
+// RFC2812, section 5.3
+const (
+ RPL_STATSCLINE = "213"
+ RPL_STATSNLINE = "214"
+ RPL_STATSILINE = "215"
+ RPL_STATSKLINE = "216"
+ RPL_STATSQLINE = "217"
+ RPL_STATSYLINE = "218"
+ RPL_SERVICEINFO = "231"
+ RPL_ENDOFSERVICES = "232"
+ RPL_SERVICE = "233"
+ RPL_STATSVLINE = "240"
+ RPL_STATSLLINE = "241"
+ RPL_STATSHLINE = "244"
+ RPL_STATSSLINE = "245"
+ RPL_STATSPING = "246"
+ RPL_STATSBLINE = "247"
+ RPL_STATSDLINE = "250"
+ RPL_NONE = "300"
+ RPL_WHOISCHANOP = "316"
+ RPL_KILLDONE = "361"
+ RPL_CLOSING = "362"
+ RPL_CLOSEEND = "363"
+ RPL_INFOSTART = "373"
+ RPL_MYPORTIS = "384"
+ ERR_NOSERVICEHOST = "492"
+)
+
+// Other constants
+const (
+ ERR_TOOMANYMATCHES = "416" // Used on IRCNet
+ RPL_TOPICWHOTIME = "333" // From ircu, in use on Freenode
+ RPL_LOCALUSERS = "265" // From aircd, Hybrid, Hybrid, Bahamut, in use on Freenode
+ RPL_GLOBALUSERS = "266" // From aircd, Hybrid, Hybrid, Bahamut, in use on Freenode
+)
diff --git a/debian/changelog b/debian/changelog
index 1d1fa3f..fe003ab 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-golang-sorcix-irc-dev (1.1.0-3) UNRELEASED; urgency=medium
+golang-sorcix-irc-dev (1.1.4-1) UNRELEASED; urgency=medium
[ Alexandre Viau ]
* Point Vcs-* urls to salsa.debian.org.
@@ -14,8 +14,9 @@ golang-sorcix-irc-dev (1.1.0-3) UNRELEASED; urgency=medium
* Set upstream metadata fields: Repository, Repository-Browse.
* Bump debhelper from deprecated 9 to 13.
* Set debhelper-compat version in Build-Depends.
+ * New upstream release.
- -- Alexandre Viau <aviau@debian.org> Mon, 02 Apr 2018 22:45:58 -0400
+ -- Alexandre Viau <aviau@debian.org> Thu, 12 Jan 2023 06:30:08 -0000
golang-sorcix-irc-dev (1.1.0-2) unstable; urgency=medium
diff --git a/doc.go b/doc.go
index 9157dcf..0effeb8 100644
--- a/doc.go
+++ b/doc.go
@@ -33,4 +33,4 @@
// // Methods from both Encoder and Decoder are available
// message, err := c.Decode()
//
-package irc // import "github.com/sorcix/irc"
+package irc
diff --git a/message.go b/message.go
index debbb64..088938d 100644
--- a/message.go
+++ b/message.go
@@ -21,10 +21,10 @@ const (
func cutsetFunc(r rune) bool {
// Characters to trim from prefixes/messages.
- return r == '\r' || r == '\n' || r == '\x20' || r == '\x00'
+ return r == '\r' || r == '\n'
}
-// Objects implementing the Sender interface are able to send messages to an IRC server.
+// Sender represents objects that are able to send messages to an IRC server.
//
// As there might be a message queue, it is possible that Send returns a nil
// error, but the message is not sent (yet). The error value is only used when
@@ -194,9 +194,9 @@ func ParseMessage(raw string) (m *Message) {
// Extract command
if j > i {
- m.Command = raw[i:j]
+ m.Command = strings.ToUpper(raw[i:j])
} else {
- m.Command = raw[i:]
+ m.Command = strings.ToUpper(raw[i:])
// We're done here!
return m
@@ -208,7 +208,7 @@ func ParseMessage(raw string) (m *Message) {
// Find prefix for trailer
i = indexByte(raw[j:], prefix)
- if i < 0 {
+ if i < 0 || raw[j+i-1] != space {
// There is no trailing argument!
m.Params = strings.Split(raw[j:], string(space))
diff --git a/message_test.go b/message_test.go
index 3e957e8..14a4db3 100644
--- a/message_test.go
+++ b/message_test.go
@@ -5,10 +5,35 @@
package irc
import (
+ "fmt"
"reflect"
"testing"
)
+func ExampleParseMessage() {
+ message := ParseMessage("JOIN #help")
+
+ fmt.Println(message.Params[0])
+
+ // Output: #help
+}
+
+func ExampleMessage_String() {
+ message := &Message{
+ Prefix: &Prefix{
+ Name: "sorcix",
+ User: "sorcix",
+ Host: "myhostname",
+ },
+ Command: "PRIVMSG",
+ Trailing: "This is an example!",
+ }
+
+ fmt.Println(message.String())
+
+ // Output: :sorcix!sorcix@myhostname PRIVMSG :This is an example!
+}
+
var messageTests = [...]*struct {
parsed *Message
rawMessage string
@@ -254,6 +279,29 @@ var messageTests = [...]*struct {
rawMessage: "TOPIC #foo :",
rawPrefix: "",
},
+ {
+ parsed: &Message{
+ Prefix: &Prefix{
+ Name: "name",
+ User: "user",
+ Host: "example.org",
+ },
+ Command: "PRIVMSG",
+ Params: []string{"#test"},
+ Trailing: "Message with spaces at the end! ",
+ },
+ rawMessage: ":name!user@example.org PRIVMSG #test :Message with spaces at the end! ",
+ rawPrefix: "name!user@example.org",
+ hostmask: true,
+ },
+ {
+ parsed: &Message{
+ Command: "PASS",
+ Params: []string{"oauth:token_goes_here"},
+ },
+ rawMessage: "PASS oauth:token_goes_here",
+ rawPrefix: "",
+ },
}
// -----
diff --git a/stream_test.go b/stream_test.go
index 59b348a..548996f 100644
--- a/stream_test.go
+++ b/stream_test.go
@@ -6,12 +6,36 @@ package irc
import (
"bytes"
+ "crypto/tls"
"io"
+ "log"
"reflect"
"strings"
"testing"
)
+// We use the Dial function as a simple shortcut for connecting to an IRC server using a standard TCP socket.
+func ExampleDial() {
+ conn, err := Dial("irc.quakenet.org:6667")
+ if err != nil {
+ log.Fatalln("Could not connect to IRC server")
+ }
+
+ conn.Close()
+}
+
+// Use NewConn when you want to connect using something else than a standard TCP socket.
+// This example first opens an encrypted TLS connection and then uses that to communicate with the server.
+func ExampleNewConn() {
+ tconn, err := tls.Dial("tcp", "irc.quakenet.org:6667", &tls.Config{})
+ if err != nil {
+ log.Fatalln("Could not connect to IRC server")
+ }
+ conn := NewConn(tconn)
+
+ conn.Close()
+}
+
var stream = "PING port80a.se.quakenet.org\r\n:port80a.se.quakenet.org PONG port80a.se.quakenet.org :port80a.se.quakenet.org\r\nPING chat.freenode.net\r\n:wilhelm.freenode.net PONG wilhelm.freenode.net :chat.freenode.net\r\n"
var result = [...]*Message{
Debdiff
File lists identical (after any substitutions)
No differences were encountered in the control files