thoj / go-ircevent Goto Github PK
View Code? Open in Web Editor NEWEvent based IRC client library in Go (golang)
License: BSD 3-Clause "New" or "Revised" License
Event based IRC client library in Go (golang)
License: BSD 3-Clause "New" or "Revised" License
Description: neither Quit() nor Disconnect() will make a bot quit IRC. The channel still gets closed, however, so it crashes on the next message received by the connection (i.e. PING or PRIVMSG).
The error: panic: runtime error: send on closed channel
To reproduce: update to the latest code on master. Have a bot join a channel on a server and then call Quit(). See that it does not quit the server. Send it a message or ping it and see that it crashes.
panic: runtime error: send on closed channel
goroutine 46533 [running]:
runtime.panic(0x68a2c0, 0x83587e)
/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/thoj/go-ircevent.(_Connection).SendRawf(0xc2087ebe00, 0x6bdd30, 0x7,$
/root/gopath/src/github.com/thoj/go-ircevent/irc.go:241 +0xd7
github.com/thoj/go-ircevent.(_Connection).pingLoop(0xc2087ebe00)
/root/gopath/src/github.com/thoj/go-ircevent/irc.go:149 +0x1e4
created by github.com/thoj/go-ircevent.(*Connection).Connect
/root/gopath/src/github.com/thoj/go-ircevent/irc.go:359 +0xbbb
I have a bunch of streams I connect to at a specific moment and switch often between channels (I reevaluate the streams every 5 mins). When I notice I don't want to follow a stream anymore I call Connection.Quit() en in the next evaluation round I call Connection.Disconnect(). I'm guessing the call to Connection.Disconnect() seems to have a race condition where a ping is still sent but pwrite closed before that and that's when the crash happens randomly.
Edit:
This was tested on the latest commit.
I'm getting this on master at the moment:
src/github.com/thoj/go-ircevent/irc.go:355: undefined: tls.DialWithDialer
The function I am led to believe was added with Go 1.3 and CentOS 6 & Fedora 20 are still on 1.2 and 1.3 won't build on either for me.
After enough disconnects I eventually get "too many open files" errors.
diff to fix the issue: https://gist.github.com/709046
In the usual irc clients it is not very easy to write an empty line, i was using ii to test an app built on top of your library, and just echoing random text in the channel when the bug came about. If you know ii, join the test channel your example/test app connects to (with ii) and echo " " > in in the channels fifo.
Cheers ;)
(edit: the gist link was broken)
$ go get github.com/thoj/go-ircevent
src/github.com/thoj/go-ircevent/irc.go:352: undefined: tls.DialWithDialer
I'm pretty sure this shouldn't happen. I should make sure I have the crypto/tls package. but I thought you should know.
I saw the changes to the example/Makefile and made me thought of the golang way to make binaries, the Makefile is greatly simplified by using these: https://gist.github.com/708737
HTH
I have a piece of code that grabs a mediawiki site, it does it well because it comes out on stdout, but when sending to go-ircevent only first line comes out on the irc channel... anyway to make this 3-4 lines instead?
Just noticed that since I've rebuilt my bot with da78ed5 reconnect on ping timeout stopped working:
2016/03/11 05:50:38 <-- :[email protected] QUIT :Ping timeout: 250 seconds
2016/03/11 05:54:29 --> PING 1457675669498722486
2016/03/11 05:54:29 Error, disconnected: write tcp 172.17.0.2:49177->193.10.255.100:7000: write: broken pipe
I suspect fix from #69 stopped working when da78ed5 got introduced.
Can anyone else replicate this behaviour?
can't see "done", can't stop
func main() {
ircobj := irc.IRC("<nick>", "<user>") //Create new ircobj
ircobj.Connect("10.95.96.86:16667") //Connect to server
ircobj.Disconnect()
log.Println("done")
}
Hey, I love the library and already wrote a small bot with it. A problem I face though is that I can't see from where the privmsg comes from.
It would be nice if I could see if the message came from a channel or from a query.
I found that I could see the channel via e.Raw but there should be an easier way imo?
I noticed when I change the nick it is not reflected in nickcurrent. I was just debugging not that I really need it.
greets
Is this my own fault? (https://github.com/ugjka/reddit-irc-bot/blob/master/bot.go)
2016/11/05 17:40:51 Connected to irc.freenode.net:6666 (162.213.39.42:6666)
==================
WARNING: DATA RACE
Read at 0x00c42007c958 by goroutine 13:
github.com/thoj/go-ircevent.(*Connection).pingLoop()
/home/ugjka/goworks/src/github.com/thoj/go-ircevent/irc.go:167 +0x1f9
Previous write at 0x00c42007c958 by goroutine 11:
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/ugjka/goworks/src/github.com/thoj/go-ircevent/irc.go:77 +0x41f
Goroutine 13 (running) created at:
github.com/thoj/go-ircevent.(*Connection).Connect()
/home/ugjka/goworks/src/github.com/thoj/go-ircevent/irc.go:437 +0xd29
github.com/ugjka/reddit-irc-bot.Start()
/home/ugjka/goworks/src/github.com/ugjka/reddit-irc-bot/bot.go:156 +0x1a5
main.main()
/home/ugjka/goworks/src/oneshots/redditbot.go:23 +0xad
Goroutine 11 (running) created at:
github.com/thoj/go-ircevent.(*Connection).Connect()
/home/ugjka/goworks/src/github.com/thoj/go-ircevent/irc.go:435 +0xcdf
github.com/ugjka/reddit-irc-bot.Start()
/home/ugjka/goworks/src/github.com/ugjka/reddit-irc-bot/bot.go:156 +0x1a5
main.main()
/home/ugjka/goworks/src/oneshots/redditbot.go:23 +0xad
When I run the tests with -race, there are a number or race conditions. It may be worth fixing them.
==================
WARNING: DATA RACE
Write by goroutine 31:
github.com/thoj/go-ircevent.(*Connection).Quit()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:216 +0x276
github.com/thoj/go-ircevent.TestConnection.func5()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:218 +0x22b
github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3
Previous read by goroutine 34:
github.com/thoj/go-ircevent.(*Connection).Loop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:190 +0x83
Goroutine 31 (running) created at:
github.com/thoj/go-ircevent.(*Connection).Connect()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:436 +0x11f7
github.com/thoj/go-ircevent.TestConnection()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:233 +0x858
testing.tRunner()
/usr/lib/go/src/testing/testing.go:473 +0xdc
Goroutine 34 (running) created at:
github.com/thoj/go-ircevent.TestConnection()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:239 +0xadb
testing.tRunner()
/usr/lib/go/src/testing/testing.go:473 +0xdc
==================
==================
WARNING: DATA RACE
Write by goroutine 36:
runtime.mapassign1()
/usr/lib/go/src/runtime/hashmap.go:429 +0x0
github.com/thoj/go-ircevent.(*Connection).ClearCallback()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:50 +0x170
github.com/thoj/go-ircevent.(*Connection).Disconnect()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:346 +0xdc
Previous read by goroutine 31:
runtime.mapaccess2_faststr()
/usr/lib/go/src/runtime/hashmap_fast.go:298 +0x0
github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:124 +0x7c9
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3
Goroutine 36 (running) created at:
github.com/thoj/go-ircevent.(*Connection).setupCallbacks.func1()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:141 +0x41
github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3
Goroutine 31 (finished) created at:
github.com/thoj/go-ircevent.(*Connection).Connect()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:436 +0x11f7
github.com/thoj/go-ircevent.TestConnection()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:233 +0x858
testing.tRunner()
/usr/lib/go/src/testing/testing.go:473 +0xdc
==================
==================
WARNING: DATA RACE
Write by goroutine 36:
github.com/thoj/go-ircevent.(*Connection).Disconnect()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:352 +0x167
Previous read by goroutine 32:
github.com/thoj/go-ircevent.(*Connection).writeLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:129 +0xb9
Goroutine 36 (running) created at:
github.com/thoj/go-ircevent.(*Connection).setupCallbacks.func1()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:141 +0x41
github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3
Goroutine 32 (finished) created at:
github.com/thoj/go-ircevent.(*Connection).Connect()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:437 +0x121c
github.com/thoj/go-ircevent.TestConnection()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:233 +0x858
testing.tRunner()
/usr/lib/go/src/testing/testing.go:473 +0xdc
==================
==================
WARNING: DATA RACE
Write by goroutine 35:
github.com/thoj/go-ircevent.(*Connection).Quit()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:216 +0x276
github.com/thoj/go-ircevent.TestConnection.func3.1()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:203 +0x1eb
Previous read by goroutine 20:
github.com/thoj/go-ircevent.(*Connection).Loop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:190 +0x83
github.com/thoj/go-ircevent.TestConnection()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:240 +0xae9
testing.tRunner()
/usr/lib/go/src/testing/testing.go:473 +0xdc
Goroutine 35 (running) created at:
github.com/thoj/go-ircevent.TestConnection.func3()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:206 +0x54
github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3
Goroutine 20 (running) created at:
testing.RunTests()
/usr/lib/go/src/testing/testing.go:582 +0xae2
testing.(*M).Run()
/usr/lib/go/src/testing/testing.go:515 +0x11d
main.main()
github.com/thoj/go-ircevent/_test/_testmain.go:84 +0x210
==================
==================
WARNING: DATA RACE
Write by goroutine 43:
github.com/thoj/go-ircevent.(*Connection).Quit()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:216 +0x276
github.com/thoj/go-ircevent.TestConnectionSSL.func2()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:254 +0x77
github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3
Previous read by goroutine 38:
github.com/thoj/go-ircevent.(*Connection).Loop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:190 +0x83
github.com/thoj/go-ircevent.TestConnectionSSL()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:263 +0x50b
testing.tRunner()
/usr/lib/go/src/testing/testing.go:473 +0xdc
Goroutine 43 (running) created at:
github.com/thoj/go-ircevent.(*Connection).Connect()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:436 +0x11f7
github.com/thoj/go-ircevent.TestConnectionSSL()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:257 +0x2ca
testing.tRunner()
/usr/lib/go/src/testing/testing.go:473 +0xdc
Goroutine 38 (running) created at:
testing.RunTests()
/usr/lib/go/src/testing/testing.go:582 +0xae2
testing.(*M).Run()
/usr/lib/go/src/testing/testing.go:515 +0x11d
main.main()
github.com/thoj/go-ircevent/_test/_testmain.go:84 +0x210
==================
==================
WARNING: DATA RACE
Write by goroutine 46:
github.com/thoj/go-ircevent.(*Connection).Disconnect()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:352 +0x167
Previous read by goroutine 43:
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:50 +0x1be
Goroutine 46 (running) created at:
github.com/thoj/go-ircevent.(*Connection).setupCallbacks.func1()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:141 +0x41
github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_callback.go:118 +0x737
github.com/thoj/go-ircevent.(*Connection).readLoop()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:82 +0x7c3
Goroutine 43 (finished) created at:
github.com/thoj/go-ircevent.(*Connection).Connect()
/home/belak/go/src/github.com/thoj/go-ircevent/irc.go:436 +0x11f7
github.com/thoj/go-ircevent.TestConnectionSSL()
/home/belak/go/src/github.com/thoj/go-ircevent/irc_test.go:257 +0x2ca
testing.tRunner()
/usr/lib/go/src/testing/testing.go:473 +0xdc
==================
Found 6 data race(s)
Attempting to use GetName results in bot.go:46: undefined: irc.GetName
I also can't find any other way to get my current nickname
quit works, all i need to do is conn.SendRaw("quit"), but it cases all sorts of horrid error messages when the go program exits (seems like it's unexpected).
Right now, it seems like go has an issue with a "standard" (http://xkcd.com/927/) IRC library... it would be really nice if all the main frameworks started standardizing around something, whether that's the Line parsing in fluffle/goirc, the Message parsing from sorcix/irc, the Message parsing from belak/irc, or the Event parsing from this library...
I'd like to propose switching to one of them and translating messages to the ircevent.Events. I would be willing to do the work, if there could be some consensus as to which one we'd want to use.
Also, is there anywhere else that would be good to discuss this? Somewhere we could pull in all the people who work on these libraries?
If this isn't something you want to do, you're welcome to close this, I'm just not sure of a better place to put this.
I was able to trigger a panic:
2017/11/07 00:53:29 <-- ERROR :quit
2017/11/07 00:53:29 ERROR (1) >> &irc.Event{Code:"ERROR", Raw:"ERROR :quit", Nick:"", Host:"", Source:"", User:"", Arguments:[]string{"quit"}, Connection:(*irc.Connection)(0xc42009a000)}
2017/11/07 00:53:29 Error, disconnected: EOF
panic: close of closed channel
goroutine 9 [running]:
github.com/thoj/go-ircevent.(*Connection).Disconnect(0xc42009a000)
/Users/prologic/go/src/github.com/thoj/go-ircevent/irc.go:348 +0x1f4
created by github.com/thoj/go-ircevent.(*Connection).setupCallbacks.func1
/Users/prologic/go/src/github.com/thoj/go-ircevent/irc_callback.go:141 +0x3e
If I kill the connection nothing happens (apart from PING beinng sent). If I do .Disconnect() nothing happens same with Reconnect()
I'm still learning go so I don't understand what is happening
new to golang but following this example to create a bot for fun,
https://waterpigs.co.uk/articles/a-simple-go-irc-bot/
but getting this msg below
line 25: cannot convert e.Message (type func() string) to type string
since I am copying and pasting I wonder if a new version of golang have made somechanges that that example does not work anymore?
is trying to echo the eMessage that is a msg sent to the irc channel...
im sure this is very simple solution just trying to understand whats wrong.
thanks
I had a bot I wrote using this lib crash the other day with a slice bounds out of range
error at irc_callback.go: 84. Sadly, I didn't have verbosity on at the time, so I wasn't able to see the message that generated it, but I suspect it was something that started with \0x01
and did contain another \0x01
. This would mean that the slice would evaluate to
msg = msg[1:0]
Which panics. I'll update the bug if I see it again, but it might be worth adding a check.
Hi,
Trying to connect to irc.smoothirc.net:6697 with ssl, the only output i receive in debug mode is
2016/11/07 16:56:11 remote error: handshake failure
I guess its related to the tls stack of go, but I cant say for sure with this output.
Edit : port corrected
A library shouldnt log something or at least provide an option to turn it off.
I mean this line: https://github.com/thoj/go-ircevent/blob/master/irc.go#L468
I don't know if it's an issue with go-ircevent, but as it happens on the reconnect login I think it might be.
I run my app on heroku and from time to time It start getting dns errors and the memory consumption goes sky high, here's an actual log, look at the memory consumption.
Can it be a memory leak on the reconnect logic? Or is it a heroku specific issue?
Nov 14 15:56:14 go-bot heroku/worker.1: Process running mem=901M(176.1%)
Nov 14 15:56:14 go-bot heroku/worker.1: Error R14 (Memory quota exceeded)
Nov 14 15:56:14 go-bot app/worker.1: 2014/11/14 17:56:14 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:15 go-bot app/worker.1: 2014/11/14 17:56:15 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:17 go-bot app/worker.1: 2014/11/14 17:56:16 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:18 go-bot app/worker.1: 2014/11/14 17:56:17 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:19 go-bot app/worker.1: 2014/11/14 17:56:19 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:20 go-bot app/worker.1: 2014/11/14 17:56:20 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:21 go-bot app/worker.1: 2014/11/14 17:56:21 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:22 go-bot app/worker.1: 2014/11/14 17:56:22 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:24 go-bot app/worker.1: 2014/11/14 17:56:23 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:25 go-bot app/worker.1: 2014/11/14 17:56:25 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:26 go-bot app/worker.1: 2014/11/14 17:56:26 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:27 go-bot app/worker.1: 2014/11/14 17:56:27 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:29 go-bot app/worker.1: 2014/11/14 17:56:28 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:30 go-bot app/worker.1: 2014/11/14 17:56:30 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:31 go-bot app/worker.1: 2014/11/14 17:56:31 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:33 go-bot app/worker.1: 2014/11/14 17:56:33 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:34 go-bot app/worker.1: 2014/11/14 17:56:34 Error while reconnecting: dial tcp: lookup example.irc.slack.com: Temporary failure in name resolution
Nov 14 15:56:35 go-bot heroku/worker.1: Process running mem=901M(176.1%)
When connection drops and ping timeout triggers reconnect this line tries to close already closed channel:
2015/08/24 23:28:04 Lag: 121.405416mss
2015/08/24 23:30:24 <-- PING :asimov.freenode.net
2015/08/24 23:30:24 --> PONG :asimov.freenode.net
2015/08/24 23:32:39 <-- PING :asimov.freenode.net
2015/08/24 23:32:39 --> PONG :asimov.freenode.net
2015/08/24 23:34:54 <-- :[email protected] QUIT :Ping timeout: 255 seconds
2015/08/24 23:34:54 <-- ERROR :Closing Link: host.foo (Ping timeout: 255 seconds)
2015/08/24 23:34:54 Error, disconnected: EOF
panic: close of closed channel
goroutine 1 [running]:
github.com/thoj/go-ircevent.(*Connection).Reconnect(0xc8200905a0, 0x0, 0x0)
/go/src/github.com/thoj/go-ircevent/irc.go:362 +0x38
github.com/thoj/go-ircevent.(*Connection).Loop(0xc8200905a0)
/go/src/github.com/thoj/go-ircevent/irc.go:199 +0x1ac
main.ircLoop()
/meowkov/meowkov.go:222 +0x28d
main.main()
/meowkov/meowkov.go:135 +0x8f
goroutine 17 [syscall, 3318 minutes, locked to thread]:
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:1696 +0x1
goroutine 4 [chan send]:
github.com/thoj/go-ircevent.(*Connection).readLoop(0xc8200905a0)
/go/src/github.com/thoj/go-ircevent/irc.go:69 +0x38c
created by github.com/thoj/go-ircevent.(*Connection).Connect
/go/src/github.com/thoj/go-ircevent/irc.go:425 +0xd22
goroutine 18678 [semacquire]:
sync.runtime_Semacquire(0xc8200905ac)
/usr/local/go/src/runtime/sema.go:43 +0x26
sync.(*WaitGroup).Wait(0xc8200905a0)
/usr/local/go/src/sync/waitgroup.go:126 +0xb4
github.com/thoj/go-ircevent.(*Connection).Disconnect(0xc8200905a0)
/go/src/github.com/thoj/go-ircevent/irc.go:352 +0x11e
github.com/thoj/go-ircevent.(*Connection).setupCallbacks.func1(0xc8200a2180)
/go/src/github.com/thoj/go-ircevent/irc_callback.go:145 +0x20
created by github.com/thoj/go-ircevent.(*Connection).RunCallbacks
/go/src/github.com/thoj/go-ircevent/irc_callback.go:123 +0x524
I did not dig into this yet, perhaps @dainis (who authored that part in f69e2d3) sees a quick fix?
It seems that this is a regression, as the same issue was fixed in 2014 in #33
Is it possible to associate an event to a particular channel? I've looked at the structs and haven't found anything useful.
For example, if I have a callback for PRIVMSG, is it possible to from what channel it came from?
Add *irc.Event.Reply(msg string)
irc.currentnick remains empty when irc.nick is unavailable or already been taken in the beginning of the connection.
I'm planning on making an AUR package.
Is there a simple way to get a list of all the nicks in a channel?
here is a patch: https://gist.github.com/705969
this replaces appendCallback with the new append idiom in go.
I created this while tracking down a bug in my app
HTH
I can see the "stipped" flag in the irc_struct.go :
type Connection struct {
.....
.....
stopped bool
}
but I can't use it to judge disconnect in my own package?
So I want to know which function I can check whether it was disconnect ,so that I can reconnect to the IRC server?
My client had a panic when it was kicked from a channel. It was from a channel the irc server mandates you join, if that makes a difference. Here's the output:
panic: runtime error: send on closed channel
goroutine 1 [running]:
github.com/thoj/Go-IRC-Client-Library.(*IRCConnection).Reconnect(0xf84006b000, 0x6f7272450000000a, 0x7f22bf288ec8, 0x100000001)
/home/reynir/contrib/go/src/pkg/github.com/thoj/Go-IRC-Client-Library/irc.go:148 +0x3c6
github.com/thoj/Go-IRC-Client-Library.(*IRCConnection).Loop(0xf84006b000, 0x4e481c)
/home/reynir/contrib/go/src/pkg/github.com/thoj/Go-IRC-Client-Library/irc.go:161 +0x141
main.main()
/home/reynir/src/cs-bot/main.go:79 +0x324
goroutine 2 [syscall]:
created by runtime.main
/tmp/bindist510773444/go/src/pkg/runtime/proc.c:221
goroutine 3 [syscall]:
syscall.Syscall6()
/tmp/bindist510773444/go/src/pkg/syscall/asm_linux_amd64.s:40 +0x5
syscall.EpollWait(0xf800000006, 0xf8400700c0, 0xa0000000a, 0xffffffff, 0xc, ...)
/usr/local/go/src/pkg/syscall/zerrors_linux_amd64.go:1781 +0xa1
net.(*pollster).WaitFD(0xf8400700b0, 0xf840038c40, 0x0, 0x0, 0x0, ...)
/usr/local/go/src/pkg/net/fd_linux.go:146 +0x110
net.(*pollServer).Run(0xf840038c40, 0x0)
/usr/local/go/src/pkg/net/fd.go:236 +0xe4
created by net.newPollServer
/usr/local/go/src/pkg/net/newpollserver.go:35 +0x382
goroutine 17 [runnable]:
github.com/thoj/Go-IRC-Client-Library.reader(0xf84006b000, 0x0)
/home/reynir/contrib/go/src/pkg/github.com/thoj/Go-IRC-Client-Library/irc.go:21
created by github.com/thoj/Go-IRC-Client-Library.(*IRCConnection).Reconnect
/home/reynir/contrib/go/src/pkg/github.com/thoj/Go-IRC-Client-Library/irc.go:146 +0x2da
goroutine 18 [runnable]:
github.com/thoj/Go-IRC-Client-Library.writer(0xf84006b000, 0x0)
/home/reynir/contrib/go/src/pkg/github.com/thoj/Go-IRC-Client-Library/irc.go:59
created by github.com/thoj/Go-IRC-Client-Library.(*IRCConnection).Reconnect
/home/reynir/contrib/go/src/pkg/github.com/thoj/Go-IRC-Client-Library/irc.go:147 +0x2f4
goroutine 6 [select]:
github.com/thoj/Go-IRC-Client-Library.pinger(0xf84006b000, 0x0)
/home/reynir/contrib/go/src/pkg/github.com/thoj/Go-IRC-Client-Library/irc.go:81 +0x463
created by github.com/thoj/Go-IRC-Client-Library.(*IRCConnection).Connect
/home/reynir/contrib/go/src/pkg/github.com/thoj/Go-IRC-Client-Library/irc.go:185 +0x3b6
goroutine 7 [syscall]:
created by addtimer
/tmp/bindist510773444/go/src/pkg/runtime/ztime_amd64.c:69
Hey there, how can I achieve this with the library?
Some commands/callbacks should only be executed if it's executed by operators/halfops etc.
To import the project, one must import it like:
import "github.com/thoj/go-ircevent"
Then to use the package:
irc.IRC(...)
irc.Connection{}
irc.Event{}
// not ircevent.IRC(...)
// not ircevent.Connection{}
// not ircevent.Event{}
The problem here is that the package string misleads as to the package name.
It would be nice if either the import string or the package name could be changed to be consistent.
I experienced some confusion trying to consume this library (#86 (comment)), as there are no recent versions tagged. This causes dependency management tools to vendor very old (buggy) code.
http://tools.ietf.org/html/rfc1459.html#section-2.3.1
In the notes section (#2), it says that "After extracting the parameter list, all parameters are equal, whether matched by or . is just a syntactic trick to allow SPACE within parameter."
The trouble in go-ircevent is that parameters matched by are not treated as equal. They are separated into the .Message
field.
For instance, on Freenode (ircd-seven), when a user joins a channel it looks like this: :Shibumi!~Shibumi@unaffiliated/sh1bumi JOIN #archlinux
However, on other ircds, such as Unreal it can look like this: :belak!belak@NeedsANewVHost JOIN :#testing
Both of these will be parsed differently by go-ircevent because of the : before the channel in the second example which can make writing bots that work on multiple networks a pain.
The simplest workaround I can think of (and possibly the most "accurate") would be to add the message as the last Argument, if there is a message.
Optionally, it could work the other way, where the last argument would be copied to the Message, if there isn't a message yet.
I tried to add two joins to eventcode 001 and this is how i discovered the bug (the default callbacs that are set up in setupcallbacks only add maximum one callback for each eventcode).
Package tests run a second connection with go irccon.Loop()
, like here.
I've been using this code in my own libraries with -race
and discovered a bunch of race conditions, such as github.com/thoj/go-ircevent.(*Connection).RunCallbacks()
and github.com/thoj/go-ircevent.(*Connection).AddCallback()
These issues seem like they could easily be solved by adding some mutexes around unsafe operations like callback map access. I may have the time to fix this in the next few weeks, but I'm not sure.
Shouldn't line 115 be
event.Code = strings.ToUpper(args[1])
instead of event.Code = strings.ToUpper(args[0])
Would be useful to use SASL, account-notify and the like
Like this:
diff --git a/irc.go b/irc.go
index 0d9e83a..7bb6e7e 100644
--- a/irc.go
+++ b/irc.go
@@ -492,6 +492,18 @@ func (irc *Connection) Connect(server string) error {
return nil
}
+// Connect and start he client in its own goroutine
+func (irc *Connection) Start() error {
+ err := irc.Connect(irc.Server)
+ if err != nil {
+ return err
+ }
+
+ go irc.Loop()
+
+ return nil
+}
+
// Negotiate IRCv3 capabilities
func (irc *Connection) negotiateCaps() error {
saslResChan := make(chan *SASLResult)
Seems message should be a function call
irc_callback.go:163: method e.Message is not an expression, must be called
my usage:
conn:= irc.IRC(); conn.Connect(...);
then some commands. but i not using conn.Loop(), is that the problem?
readLoop:
#0 0x00000000004b95d2 in crypto/tls.(*Conn).SetReadDeadline (c=0x0, t=..., ~r1=...)
at /usr/lib/go/src/crypto/tls/conn.go:122
#1 0x000000000046985b in github.com/thoj/go-ircevent.(Connection).readLoop (irc=0xc420352840)
at /golib/src/github.com/thoj/go-ircevent/irc.go:65
#2 0x0000000000464b11 in runtime.goexit () at /usr/lib/go/src/runtime/asm_amd64.s:2086
#3 0x000000c420352840 in ?? ()
#4 0x0000000000000000 in ?? ()
writeLoop:
#0 syscall.Syscall () at /usr/lib/go/src/syscall/asm_linux_amd64.s:27
#1 0x00000000005354f5 in syscall.write (fd=10, p=..., n=119, err=...)
at /usr/lib/go/src/syscall/zsyscall_linux_amd64.go:1064
#2 0x00000000005346c9 in syscall.Write (fd=10, p=..., n=13, err=...) at /usr/lib/go/src/syscall/syscall_unix.go:180
#3 0x00000000004f8e7a in net.(*netFD).Write (fd=0xc4200edf80, p=..., nn=0, err=...) at /usr/lib/go/src/net/fd_unix.go:321
#4 0x0000000000503770 in net.(*conn).Write (c=0xc420074078, b=..., ~r1=0, ~r2=...) at /usr/lib/go/src/net/net.go:185
#5 0x00000000004c69c7 in crypto/tls.(*Conn).write (c=0xc42006f180, data=..., ~r1=842350677249, ~r2=...)
at /usr/lib/go/src/crypto/tls/conn.go:819
#6 0x00000000004c6e63 in crypto/tls.(*Conn).writeRecordLocked (c=0xc42006f180, typ=23 '\027', data=..., ~r2=0, ~r3=...)
at /usr/lib/go/src/crypto/tls/conn.go:895
#7 0x00000000004c7edb in crypto/tls.(*Conn).Write (c=0xc42006f180, b=..., ~r1=0, ~r2=...)
at /usr/lib/go/src/crypto/tls/conn.go:1047
#8 0x000000000047141b in github.com/thoj/go-ircevent.(*Connection).writeLoop (irc=0xc4200f8000)
at /golib/src/github.com/thoj/go-ircevent/irc.go:145
#9 0x000000000046b901 in runtime.goexit () at /usr/lib/go/src/runtime/asm_amd64.s:2086
#10 0x000000c4200f8000 in ?? ()
#11 0x0000000000000000 in ?? ()
hi, i discovered a bug in the pinger code.
so the pinger pings the server every 4 minutes, except if there was a message, so
for example, say i write a message 3 minutes before pinger pings, then pinger sees at 3 minutes that i have written a message, and sleeps an other 4 minutes. The problem is that 2 minutes later it's too late, 6 minjutes have gone by, the connection times out.
My solution would be to then rearrange the ticker to tick in one minute, so 4-n minutes later, where n is the time of the last message
Hope this helps,
This is somewhat of an important discussion to have. I opened it because of PR #50 (and my own experiences in the past).
Currently all callbacks are run inside a goroutine. This leads to unpredictable behavior, especially when attempting to do stuff which is order important (such as authenticating users).
I personally think that all callbacks should not be run in a goroutine, as it breaks the idea of order in IRC. Users should be able to run portions of their callbacks in a goroutine, but it should not be required.
I think I have tried everything i think
ircobj := irc.IRC(bot.Irc_nick, bot.Irc_name)
//Rejoin the channel on reconnect
ircobj.AddCallback("001", func(e *irc.Event) { ircobj.Join(bot.Irc_channel) })
//Reconnect on quit
quitEvent := regexp.MustCompile("^:([^!]+)!.+QUIT")
ircobj.AddCallback("QUIT", func(e *irc.Event) {
go func(e *irc.Event) {
ownNick := ircobj.GetNick()
quitNick := quitEvent.FindStringSubmatch(e.Raw)[1]
if ownNick == quitNick && strings.Contains(e.Raw, "Ping timeout") {
log.Println("Timeout detected, reconnecting to " + bot.Irc_server)
ircobj.Reconnect()
}
}(e)
})
//Connect Loop
for {
if err := ircobj.Connect(bot.Irc_server); err == nil {
break
} else {
log.Println(err)
}
time.Sleep(time.Second * 5)
}
ircobj.Loop()
Source https://github.com/ugjka/reddit-irc-bot/blob/master/bot.go
This is driving me mad becouse my vps where I'm hosting my irc bot often have network problems, and I have to manually restart my bot everytime. There is no log messages printed, the bot thinks that it is still connected
Here's the following output from attempting a build on Drone.io of a bot that is consuming go-ircevent. Here is the full output:
$ git clone git://github.com/darthlukan/gobot.git /home/ubuntu/src/github.com/darthlukan/gobot
Cloning into '/home/ubuntu/src/github.com/darthlukan/gobot'...
$ go version
go version go1.2 linux/amd64
$ go get
# github.com/thoj/go-ircevent
../../thoj/go-ircevent/irc.go:365: undefined: tls.DialWithDialer
I got a runtime panic because of these lines.
I'm not sure what message caused it, but here's a stack trace of it. It's from my pulled version, but I've only added a delay between reconnects.
panic: runtime error: slice bounds out of range
goroutine 32 [running]:
runtime.panic(0x744cc0, 0x983dcf)
/usr/lib/golang/src/pkg/runtime/panic.c:279 +0xf5
github.com/hspak/go-ircevent.(*Connection).RunCallbacks(0xc208278120, 0xc2080f8480)
/home/hsp/code/gocode/src/github.com/hspak/go-ircevent/irc_callback.go:84 +0xb44
github.com/hspak/go-ircevent.(*Connection).readLoop(0xc208278120)
/home/hsp/code/gocode/src/github.com/hspak/go-ircevent/irc.go:104 +0x93d
created by github.com/hspak/go-ircevent.(*Connection).Connect
/home/hsp/code/gocode/src/github.com/hspak/go-ircevent/irc.go:381 +0xae1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.