irc-go/ircevent
2021-02-19 12:03:16 -05:00
..
examples update examples, run gofmt 2021-02-19 11:45:33 -05:00
irc_callback.go initial fixes and refactoring 2021-02-19 03:55:06 -05:00
irc_ctcp.go initial fixes and refactoring 2021-02-19 03:55:06 -05:00
irc_parse_test.go initial fixes and refactoring 2021-02-19 03:55:06 -05:00
irc_sasl_test.go fail SASL tests if no environment variables set 2021-02-19 12:03:16 -05:00
irc_sasl.go initial fixes and refactoring 2021-02-19 03:55:06 -05:00
irc_struct.go update examples, run gofmt 2021-02-19 11:45:33 -05:00
irc_test.go fail SASL tests if no environment variables set 2021-02-19 12:03:16 -05:00
irc.go update examples, run gofmt 2021-02-19 11:45:33 -05:00
LICENSE initial fixes and refactoring 2021-02-19 03:55:06 -05:00
README.markdown initial fixes and refactoring 2021-02-19 03:55:06 -05:00

Description

This is an event-based IRC client library. It is a fork of thoj/go-ircevent.

Features

  • Event-based: register callbacks for IRC commands
  • Handles reconnections
  • Supports SASL
  • Supports requesting IRCv3 capabilities

Example

See examples/simple.go for a working example, but this illustrates the API:

irc := ircevent.Connection{
	Server:      "testnet.oragono.io:6697",
	UseTLS:      true,
	Nick:        "ircevent-test",
	Debug:       true,
	RequestCaps: []string{"server-time", "message-tags"},
}

irc.AddCallback("001", func(e ircevent.Event) { irc.Join("#ircevent-test") })

irc.AddCallback("PRIVMSG", func(event ircevent.Event) {
	//event.Message() contains the message
	//event.Nick() Contains the sender
	//event.Params[0] Contains the channel
});

err := irc.Connect()
if err != nil {
	log.Fatal(err)
}
irc.Loop()

The read loop will wait for all callbacks to complete before moving on to the next message. If your callback needs to trigger a long-running task, you should spin off a new goroutine for it.

Commands

These commands can be used from inside callbacks, or externally:

irc.Connect("irc.someserver.com:6667") //Connect to server
irc.Send(command, params...)
irc.SendWithTags(tags, command, params...)
irc.Join(channel)
irc.Privmsg(target, message)
irc.Privmsgf(target, formatString, params...)