Event based IRC client library in Go (golang)
Go to file
Shivaram Lingamneni ca8c401467 fix SASL stalling due to duplicated callbacks
Each reconnection would add redundant callbacks for CAP and the
SASL numerics. This would result in `AUTHENTICATE PLAIN` being sent
multiple times (once for each callback), which would confuse the server.
2021-02-11 22:37:42 -05:00
examples/simple fix import statement to correct repo name 2016-11-07 20:19:02 -06:00
go.mod Add non UTF-8 encoding support 2019-08-07 18:21:07 +09:00
go.sum Add non UTF-8 encoding support 2019-08-07 18:21:07 +09:00
irc_callback.go fix SASL stalling due to duplicated callbacks 2021-02-11 22:37:42 -05:00
irc_parse_test.go Run all callbacks in parallel 2018-05-18 15:19:14 -07:00
irc_sasl_test.go Run all callbacks in parallel 2018-05-18 15:19:14 -07:00
irc_sasl.go fix SASL stalling due to duplicated callbacks 2021-02-11 22:37:42 -05:00
irc_struct.go fix SASL stalling due to duplicated callbacks 2021-02-11 22:37:42 -05:00
irc_test_fuzz.go Move fuzzing code to seperate file 2015-07-31 21:33:36 +02:00
irc_test.go Run all callbacks in parallel 2018-05-18 15:19:14 -07:00
irc.go fix SASL stalling due to duplicated callbacks 2021-02-11 22:37:42 -05:00
LICENSE LICENSE, Same as go itself. 2009-11-18 16:03:14 +01:00
README.markdown Link to example in README 2016-11-05 19:17:13 +01:00

Description

Event based irc client library.

Features

  • Event based. Register Callbacks for the events you need to handle.
  • Handles basic irc demands for you
    • Standard CTCP
    • Reconnections on errors
    • Detect stoned servers

Install

$ go get github.com/thoj/go-ircevent

Example

See examples/simple/simple.go and irc_test.go

Events for callbacks

  • 001 Welcome
  • PING
  • CTCP Unknown CTCP
  • CTCP_VERSION Version request (Handled internaly)
  • CTCP_USERINFO
  • CTCP_CLIENTINFO
  • CTCP_TIME
  • CTCP_PING
  • CTCP_ACTION (/me)
  • PRIVMSG
  • MODE
  • JOIN

+Many more

AddCallback Example

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

Please note: Callbacks are run in the main thread. If a callback needs a long time to execute please run it in a new thread.

Example:

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

Commands

ircobj := irc.IRC("<nick>", "<user>") //Create new ircobj
//Set options
ircobj.UseTLS = true //default is false
//ircobj.TLSOptions //set ssl options
ircobj.Password = "[server password]"
//Commands
ircobj.Connect("irc.someserver.com:6667") //Connect to server
ircobj.SendRaw("<string>") //sends string to server. Adds \r\n
ircobj.SendRawf("<formatstring>", ...) //sends formatted string to server.n
ircobj.Join("<#channel> [password]") 
ircobj.Nick("newnick") 
ircobj.Privmsg("<nickname | #channel>", "msg") // sends a message to either a certain nick or a channel
ircobj.Privmsgf(<nickname | #channel>, "<formatstring>", ...)
ircobj.Notice("<nickname | #channel>", "msg")
ircobj.Noticef("<nickname | #channel>", "<formatstring>", ...)