diff options
Diffstat (limited to 'vendor/github.com/lrstanley')
-rw-r--r-- | vendor/github.com/lrstanley/girc/.travis.yml | 26 | ||||
-rw-r--r-- | vendor/github.com/lrstanley/girc/CONTRIBUTING.md | 32 | ||||
-rw-r--r-- | vendor/github.com/lrstanley/girc/README.md | 99 | ||||
-rw-r--r-- | vendor/github.com/lrstanley/girc/cmdhandler/cmd.go | 199 |
4 files changed, 157 insertions, 199 deletions
diff --git a/vendor/github.com/lrstanley/girc/.travis.yml b/vendor/github.com/lrstanley/girc/.travis.yml new file mode 100644 index 00000000..658e65d9 --- /dev/null +++ b/vendor/github.com/lrstanley/girc/.travis.yml @@ -0,0 +1,26 @@ +language: go +go: +- 1.8 +- 1.9 +- tip +before_install: +- go get -v github.com/golang/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 . +after_success: + - bash <(curl -s https://codecov.io/bash) +branches: + only: + - master +notifications: + irc: + channels: + - irc.byteirc.org#/dev/null + template: + - "%{repository} #%{build_number} %{branch}/%{commit}: %{author} -- %{message} + %{build_url}" + on_success: change + on_failure: change + skip_join: false diff --git a/vendor/github.com/lrstanley/girc/CONTRIBUTING.md b/vendor/github.com/lrstanley/girc/CONTRIBUTING.md new file mode 100644 index 00000000..7913630c --- /dev/null +++ b/vendor/github.com/lrstanley/girc/CONTRIBUTING.md @@ -0,0 +1,32 @@ +# Contributing + +## Issue submission + + * When submitting an issue or bug report, please ensure to provide as much + information as possible, please ensure that you are running on the latest + stable version (tagged), or when using master, provide the specific commit + being used. + * Provide the minimum needed viable source to replicate the problem. + +## Pull requests + +To review what is currently being worked on, or looked into, feel free to head +over to the [issues list](../../issues). + +Below are a few guidelines if you would like to contribute. Keep the code +clean, standardized, and much of the quality should match Golang's standard +library and common idioms. + + * Always test using the latest Go version. + * Always use `gofmt` before committing anything. + * Always have proper documentation before committing. + * Keep the same whitespacing, documentation, and newline format as the + rest of the project. + * Only use 3rd party libraries if necessary. If only a small portion of + the library is needed, simply rewrite it within the library to prevent + useless imports. + * Also see [golang/go/wiki/CodeReviewComments](https://github.com/golang/go/wiki/CodeReviewComments) + +If you would like to assist, and the pull request is quite large and/or it has +the potential of being a breaking change, please open an issue first so it can +be discussed. diff --git a/vendor/github.com/lrstanley/girc/README.md b/vendor/github.com/lrstanley/girc/README.md new file mode 100644 index 00000000..ddc1193c --- /dev/null +++ b/vendor/github.com/lrstanley/girc/README.md @@ -0,0 +1,99 @@ +<p align="center"><a href="https://godoc.org/github.com/lrstanley/girc"><img width="270" src="http://i.imgur.com/DEnyrdB.png"></a></p> +<p align="center">girc, a flexible IRC library for Go</p> +<p align="center"> + <a href="https://travis-ci.org/lrstanley/girc"><img src="https://travis-ci.org/lrstanley/girc.svg?branch=master" alt="Build Status"></a> + <a href="https://codecov.io/gh/lrstanley/girc"><img src="https://codecov.io/gh/lrstanley/girc/branch/master/graph/badge.svg" alt="Coverage Status"></a> + <a href="https://godoc.org/github.com/lrstanley/girc"><img src="https://godoc.org/github.com/lrstanley/girc?status.png" alt="GoDoc"></a> + <a href="https://goreportcard.com/report/github.com/lrstanley/girc"><img src="https://goreportcard.com/badge/github.com/lrstanley/girc" alt="Go Report Card"></a> + <a href="https://byteirc.org/channel/%23%2Fdev%2Fnull"><img src="https://img.shields.io/badge/ByteIRC-%23%2Fdev%2Fnull-blue.svg" alt="IRC Chat"></a> +</p> + +## Status + +**girc is fairly close to marking the 1.0.0 endpoint, which will be tagged as +necessary, so you will be able to use this with care knowing the specific tag +you're using won't have breaking changes** + +## Features + +- Focuses on simplicity, yet tries to still be flexible. +- Only requires [standard library packages](https://godoc.org/github.com/lrstanley/girc?imports) +- Event based triggering/responses ([example](https://godoc.org/github.com/lrstanley/girc#ex-package--Commands), and [CTCP too](https://godoc.org/github.com/lrstanley/girc#Commands.SendCTCP)!) +- [Documentation](https://godoc.org/github.com/lrstanley/girc) is _mostly_ complete. +- Support for almost all of the [IRCv3 spec](http://ircv3.net/software/libraries.html). + - SASL Auth (currently only `PLAIN` and `EXTERNAL` is support by default, + however you can simply implement `SASLMech` yourself to support additional + mechanisms.) + - Message tags (things like `account-tag` on by default) + - `account-notify`, `away-notify`, `chghost`, `extended-join`, etc -- all handled seemlessly ([cap.go](https://github.com/lrstanley/girc/blob/master/cap.go) for more info). +- Channel and user tracking. Easily find what users are in a channel, if a + user is away, or if they are authenticated (if the server supports it!) +- Client state/capability tracking. Easy methods to access capability data ([LookupChannel](https://godoc.org/github.com/lrstanley/girc#Client.LookupChannel), [LookupUser](https://godoc.org/github.com/lrstanley/girc#Client.LookupUser), [GetServerOption (ISUPPORT)](https://godoc.org/github.com/lrstanley/girc#Client.GetServerOption), etc.) +- Built-in support for things you would commonly have to implement yourself. + - Nick collision detection and prevention (also see [Config.HandleNickCollide](https://godoc.org/github.com/lrstanley/girc#Config).) + - Event/message rate limiting. + - Channel, nick, and user validation methods ([IsValidChannel](https://godoc.org/github.com/lrstanley/girc#IsValidChannel), [IsValidNick](https://godoc.org/github.com/lrstanley/girc#IsValidNick), etc.) + - CTCP handling and auto-responses ([CTCP](https://godoc.org/github.com/lrstanley/girc#CTCP)) + - And more! + +## Installing + + $ go get -u github.com/lrstanley/girc + +## Examples + +See [the examples](https://godoc.org/github.com/lrstanley/girc#example-package--Bare) +within the documentation for real-world usecases. Here are a few real-world +usecases/examples/projects which utilize girc: + +| Project | Description | +| --- | --- | +| [nagios-check-ircd](https://github.com/lrstanley/nagios-check-ircd) | Nagios utility for monitoring the health of an ircd | +| [nagios-notify-irc](https://github.com/lrstanley/nagios-notify-irc) | Nagios utility for sending alerts to one or many channels/networks | +| [matterbridge](https://github.com/42wim/matterbridge) | bridge between mattermost, IRC, slack, discord (and many others) with REST API | + +Working on a project and want to add it to the list? Submit a pull request! + +## Contributing + +Please review the [CONTRIBUTING](CONTRIBUTING.md) doc for submitting issues/a guide +on submitting pull requests and helping out. + +## License + + Copyright (c) 2016 Liam Stanley <me@liamstanley.io> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +girc artwork licensed under [CC 3.0](http://creativecommons.org/licenses/by/3.0/) based on Renee French under Creative Commons 3.0 Attributions. + +## References + + * [IRCv3: Specification Docs](http://ircv3.net/irc/) + * [IRCv3: Specification Repo](https://github.com/ircv3/ircv3-specifications) + * [IRCv3 Capability Registry](http://ircv3.net/registry.html) + * [ISUPPORT Specification Docs](http://www.irc.org/tech_docs/005.html) ([alternative 1](http://defs.ircdocs.horse/defs/isupport.html), [alternative 2](https://github.com/grawity/irc-docs/blob/master/client/RPL_ISUPPORT/draft-hardy-irc-isupport-00.txt), [relevant draft](http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt)) + * [IRC Numerics List](http://defs.ircdocs.horse/defs/numerics.html) + * [Extended WHO (also known as WHOX)](https://github.com/quakenet/snircd/blob/master/doc/readme.who) + * [RFC1459: Internet Relay Chat Protocol](https://tools.ietf.org/html/rfc1459) + * [RFC2812: Internet Relay Chat: Client Protocol](https://tools.ietf.org/html/rfc2812) + * [RFC2813: Internet Relay Chat: Server Protocol](https://tools.ietf.org/html/rfc2813) + * [RFC7194: Default Port for Internet Relay Chat (IRC) via TLS/SSL](https://tools.ietf.org/html/rfc7194) + * [RFC4422: Simple Authentication and Security Layer](https://tools.ietf.org/html/rfc4422) ([SASL EXTERNAL](https://tools.ietf.org/html/rfc4422#appendix-A)) + * [RFC4616: The PLAIN SASL Mechanism](https://tools.ietf.org/html/rfc4616) diff --git a/vendor/github.com/lrstanley/girc/cmdhandler/cmd.go b/vendor/github.com/lrstanley/girc/cmdhandler/cmd.go deleted file mode 100644 index a45a42f3..00000000 --- a/vendor/github.com/lrstanley/girc/cmdhandler/cmd.go +++ /dev/null @@ -1,199 +0,0 @@ -package cmdhandler - -import ( - "errors" - "fmt" - "regexp" - "strings" - "sync" - - "github.com/lrstanley/girc" -) - -// Input is a wrapper for events, based around private messages. -type Input struct { - Origin *girc.Event - Args []string - RawArgs string -} - -// Command is an IRC command, supporting aliases, help documentation and easy -// wrapping for message inputs. -type Command struct { - // Name of command, e.g. "search" or "ping". - Name string - // Aliases for the above command, e.g. "s" for search, or "p" for "ping". - Aliases []string - // Help documentation. Should be in the format "<arg> <arg> [arg] -- - // something useful here" - Help string - // MinArgs is the minimum required arguments for the command. Defaults to - // 0, which means multiple, or no arguments can be supplied. If set - // above 0, this means that the command handler will throw an error asking - // the person to check "<prefix>help <command>" for more info. - MinArgs int - // Fn is the function which is executed when the command is ran from a - // private message, or channel. - Fn func(*girc.Client, *Input) -} - -func (c *Command) genHelp(prefix string) string { - out := "{b}" + prefix + c.Name + "{b}" - - if c.Aliases != nil && len(c.Aliases) > 0 { - out += " ({b}" + prefix + strings.Join(c.Aliases, "{b}, {b}"+prefix) + "{b})" - } - - out += " :: " + c.Help - - return out -} - -// CmdHandler is an irc command parser and execution format which you could -// use as an example for building your own version/bot. -// -// An example of how you would register this with girc: -// -// ch, err := cmdhandler.New("!") -// if err != nil { -// panic(err) -// } -// -// ch.Add(&cmdhandler.Command{ -// Name: "ping", -// Help: "Sends a pong reply back to the original user.", -// Fn: func(c *girc.Client, input *cmdhandler.Input) { -// c.Commands.ReplyTo(*input.Origin, "pong!") -// }, -// }) -// -// client.Handlers.AddHandler(girc.PRIVMSG, ch) -type CmdHandler struct { - prefix string - re *regexp.Regexp - - mu sync.Mutex - cmds map[string]*Command -} - -var cmdMatch = `^%s([a-z0-9-_]{1,20})(?: (.*))?$` - -// New returns a new CmdHandler based on the specified command prefix. A good -// prefix is a single character, and easy to remember/use. E.g. "!", or ".". -func New(prefix string) (*CmdHandler, error) { - re, err := regexp.Compile(fmt.Sprintf(cmdMatch, regexp.QuoteMeta(prefix))) - if err != nil { - return nil, err - } - - return &CmdHandler{prefix: prefix, re: re, cmds: make(map[string]*Command)}, nil -} - -var validName = regexp.MustCompile(`^[a-z0-9-_]{1,20}$`) - -// Add registers a new command to the handler. Note that you cannot remove -// commands once added, unless you add another CmdHandler to the client. -func (ch *CmdHandler) Add(cmd *Command) error { - if cmd == nil { - return errors.New("nil command provided to CmdHandler") - } - - cmd.Name = strings.ToLower(cmd.Name) - if !validName.MatchString(cmd.Name) { - return fmt.Errorf("invalid command name: %q (req: %q)", cmd.Name, validName.String()) - } - - if cmd.Aliases != nil { - for i := 0; i < len(cmd.Aliases); i++ { - cmd.Aliases[i] = strings.ToLower(cmd.Aliases[i]) - if !validName.MatchString(cmd.Aliases[i]) { - return fmt.Errorf("invalid command name: %q (req: %q)", cmd.Aliases[i], validName.String()) - } - } - } - - if cmd.MinArgs < 0 { - cmd.MinArgs = 0 - } - - ch.mu.Lock() - defer ch.mu.Unlock() - - if _, ok := ch.cmds[cmd.Name]; ok { - return fmt.Errorf("command already registered: %s", cmd.Name) - } - - ch.cmds[cmd.Name] = cmd - - // Since we'd be storing pointers, duplicates do not matter. - for i := 0; i < len(cmd.Aliases); i++ { - if _, ok := ch.cmds[cmd.Aliases[i]]; ok { - return fmt.Errorf("alias already registered: %s", cmd.Aliases[i]) - } - - ch.cmds[cmd.Aliases[i]] = cmd - } - - return nil -} - -// Execute satisfies the girc.Handler interface. -func (ch *CmdHandler) Execute(client *girc.Client, event girc.Event) { - if event.Source == nil || event.Command != girc.PRIVMSG { - return - } - - parsed := ch.re.FindStringSubmatch(event.Trailing) - if len(parsed) != 3 { - return - } - - invCmd := strings.ToLower(parsed[1]) - args := strings.Split(parsed[2], " ") - if len(args) == 1 && args[0] == "" { - args = []string{} - } - - ch.mu.Lock() - defer ch.mu.Unlock() - - if invCmd == "help" { - if len(args) == 0 { - client.Cmd.ReplyTo(event, girc.Fmt("type '{b}!help {blue}<command>{c}{b}' to optionally get more info about a specific command.")) - return - } - - args[0] = strings.ToLower(args[0]) - - if _, ok := ch.cmds[args[0]]; !ok { - client.Cmd.ReplyTof(event, girc.Fmt("unknown command {b}%q{b}."), args[0]) - return - } - - if ch.cmds[args[0]].Help == "" { - client.Cmd.ReplyTof(event, girc.Fmt("there is no help documentation for {b}%q{b}"), args[0]) - return - } - - client.Cmd.ReplyTo(event, girc.Fmt(ch.cmds[args[0]].genHelp(ch.prefix))) - return - } - - cmd, ok := ch.cmds[invCmd] - if !ok { - return - } - - if len(args) < cmd.MinArgs { - client.Cmd.ReplyTof(event, girc.Fmt("not enough arguments supplied for {b}%q{b}. try '{b}%shelp %s{b}'?"), invCmd, ch.prefix, invCmd) - return - } - - in := &Input{ - Origin: &event, - Args: args, - RawArgs: parsed[2], - } - - go cmd.Fn(client, in) -} |