dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.2.5
postmodern has joined #cinch
rikai has quit [Ping timeout: 240 seconds]
rikai has joined #cinch
sarkyniin has joined #cinch
sarkyniin has quit [Remote host closed the connection]
postmodern has quit [Quit: Leaving]
sarkyniin has joined #cinch
apt-get_ has joined #cinch
sarkyniin has quit [Ping timeout: 250 seconds]
apt-get_ has quit [Remote host closed the connection]
britneywright has joined #cinch
britneywright has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sarkyniin has joined #cinch
olistik has joined #cinch
<olistik> hi guys
<olistik> I'm playing around with cinch
<olistik> just testing a simple bot that logs everything the users say in a given channel
<olistik> this is what I've created so far: https://gist.github.com/olistik/f68e1af5cedd1c45dde9
<olistik> two areas are still obscure to me:
<olistik> 1) how to properly log the messages I receive via the hook into a file
<olistik> 2) how to properly make Cinch quit
<olistik> do you have any suggestion?
<olistik> leftylink: I need to send it by a command given to the process, not received by an irc callback
<leftylink> olistik: it looks like http://www.rubydoc.info/gems/cinch/file/docs/logging.md has an example for logging to a file (haven't tried it myself, but it looks reasonable)
<olistik> leftylink: thanks, I'm taking a look at that approach for logging :-)
<leftylink> olistik: doh, I failed to read your gist, I see you tried bot.quit on your signal handler. hmm.
<leftylink> gonna havee a think
<olistik> I've seen this PR: https://github.com/cinchrb/cinch/pull/195
<olistik> mmh, it doesn't seem what I'm looking for..
<leftylink> I think it could be, but I wonder if there is another way to make it happen
<olistik> with this trick I can't see exceptions anymore
<olistik> but I'm not sure bot.quit has been called properly..
<olistik> indeed, the message I can see from the bot quitting is only this one: "peephole-42 has left IRC (Client Quit)"
<olistik> so, it quits gracefully but without sending the proper quit message
<leftylink> we should check whether the irc server in question is respecting client-sent quit messages (and we can also check in logs whether the bot sent the right quit message)
<leftylink> it is an interesting question though
<olistik> I'm using irc.freenode.org on #bot-test
<olistik> I think I'll dive deeper into Cinch internals
<olistik> imo, it would be better to provide system callbacks out of the box
<dominikh> a) most channels block the quit messages of unregistered users b) I have no idea what you mean by system callbacks
<olistik> dominikh: b) responding to signals sent to the process running the cinch client
<olistik> dominikh: a) that's probably the case :-)
<dominikh> that's none of cinch's business. cinch handles irc, not the process abstraction of your OS
<olistik> dominikh: regarding b) is there another way, not implying sending irc messages, to gracefully stop the process
<olistik> ?
<dominikh> yes. call Bot#quit.
<dominikh> it doesn't care where or why the method gets called
<leftylink> even if my bot identifies, freenode isn't taking its quit message. perhaps freenode just doesn't take quit messages from anyone
<olistik> dominikh: is everything alright? :-) Just asking questions here..
<dominikh> install a signal handler (trap) and do your thing
<dominikh> leftylink: iirc there's a channel mode to block quit messages in general. generally speaking, freenode does allow them.
<olistik> Signal.trap('INT') do |signal_number|
<olistik> bot.quit
<olistik> exit 0
<olistik> end
<dominikh> for example.
<leftylink> yeah what happens there is ^C/home/leftylink/.gem/ruby/2.2.0/gems/cinch-2.2.3/lib/cinch/message_queue.rb:46:in `synchronize': can't be called from trap context (ThreadError)
<leftylink> so I had to cheat and do the similar thing to olistik in the form of https://gist.github.com/an1itdp01y/62f8c870f3554d02dcf7
<olistik> The problem with the snippet above is that whenever I send a SIGINT to the process..
<dominikh> wtf
<olistik> exactly, just like leftylink said :-)
<dominikh> bloody ruby 2
<leftylink> spaghettios
<dominikh> I'll take a look when I'm at the PC
<leftylink> hmmhmmhmm https://github.com/ruby/ruby/blob/ruby_2_0_0/thread.c#L4303 hmmhmmhmm I'm not sure we can set allow_trap
<leftylink> I'll have to have a think about it later
<olistik> thanks for your time
<leftylink> so I take it that means it would work on ruby 1.9 eh? interesting. I would miss keyword args though :'(
<leftylink> there's a bot that I write for someone else to run and I can't use keyword args cuz that server only has ruby 1.9 :'(
<dominikh> at least I think so. didn't have that issue on 1.9 as far as I can remember
<dominikh> https://github.com/eventmachine/eventmachine/issues/418 at least we're not alone :P
<leftylink> yeah I don't see anything if I search "trap context" in https://github.com/ruby/ruby/blob/ruby_1_9_3/thread.c
<leftylink> so it's an interesting question
<leftylink> oh... ohmy
<leftylink> this workaround
<dominikh> the only valid workaround I can think of involves polling a variable, and that sounds awful
<leftylink> this may be better suited for a ruby-internals place or something but perhaps I collect my thoughts somewhere before bringing them somewhere public
<leftylink> s/public/more public/ I guess
<leftylink> acquiring a mutex could block for an unknown amount of time, so I guess it could be a noble cause to say you shouldn't do that in a trap
<leftylink> and yet, Thread.join is OK, apparently? and that also implies we're doing a context switch inside a trap. well, I hope that's not unsafe
<leftylink> oy vey
<leftylink> I'll look at message_queue and see if I can think of something, but polling does sound quite silly
<dominikh> technically, Ruby 2's behaviour is more correct than that of 1.9. a trap *should* do the minimal amount of work, that's been known outside of Ruby for a long time
<dominikh> but it's also a pain in the ass
<leftylink> also I think I made a conceptual error... of course it should be OK to do a context swich inside a trap... all context swiches happen inside traps. but I guess I was complaining about context switches that the user specifically requests, rather than the system
<leftylink> heh
apt-get_ has joined #cinch
sarkyniin has quit [Ping timeout: 252 seconds]
Wobbley has quit [Remote host closed the connection]
green-big-frog has quit [Quit: Does this rag smell like chloroform to you?]
argoneus has quit [Ping timeout: 255 seconds]
argoneus has joined #cinch
postmodern has joined #cinch
Wobbley has joined #cinch
Azure has quit [Quit: Oops.]
Azure has joined #cinch
apt-get_ has quit [Ping timeout: 256 seconds]
apt-get_ has joined #cinch
apt-get_ has quit [Client Quit]
Azure has quit [Ping timeout: 255 seconds]
Azure has joined #cinch
thews has quit [Read error: Connection reset by peer]
thews has joined #cinch