irc-go/ircevent
2023-02-07 20:11:01 -08:00
..
examples fix #64 2022-06-20 00:24:08 -04:00
irc.go fix #64 2022-06-20 00:24:08 -04:00
irc_callback.go fix #84 2022-06-17 18:08:43 -04:00
irc_ctcp.go rename (*ircmsg.Message).Name back to Nick 2022-01-13 04:35:19 -05:00
irc_labeledresponse_test.go ircevent: add synchronous GetLabeledResponse API 2022-05-23 14:26:13 -04:00
irc_parse_test.go rename to Message and Reader; remove Event 2021-03-10 18:08:37 -05:00
irc_sasl.go remove ircmap and gircclient, rename to ergochat/irc-go 2021-06-17 16:51:48 -04:00
irc_sasl_test.go remove ircmap and gircclient, rename to ergochat/irc-go 2021-06-17 16:51:48 -04:00
irc_struct.go fix #64 2022-06-20 00:24:08 -04:00
irc_test.go add ircfmt.Split, rewrite ircfmt.Strip (#89) 2023-01-29 21:02:45 -05:00
LICENSE initial fixes and refactoring 2021-02-19 03:55:06 -05:00
numerics.go add additional numeric definitions 2022-05-23 22:01:39 -04:00
README.markdown update ircevent readme 2022-04-06 21:42:06 -04:00

Description

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

Features

Example

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

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

irc.AddConnectCallback(func(e ircmsg.Message) { irc.Join("#ircevent-test") })

irc.AddCallback("PRIVMSG", func(event ircmsg.Message) {
	// event.Source is the source;
	// event.Params[0] is the target (the channel or nickname the message was sent to)
	// and event.Params[1] is the message itself
});

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

The read loop executes all callbacks in serial on a single goroutine, respecting the order in which messages are received from the server. All callbacks must complete before the next message can be processed; if your callback needs to trigger a long-running task, you should spin off a new goroutine for it.

Commands

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

irc.Send(command, params...)
irc.SendWithTags(tags, command, params...)
irc.Join(channel)
irc.Privmsg(target, message)
irc.Privmsgf(target, formatString, params...)

The ircevent.Connection object is synchronized internally, so these methods can be run from any goroutine without external locking.