dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.2.5
bosma has joined #cinch
<bosma> I do https://gist.github.com/anonymous/09c8e18ef5e349a6e371 to set a value from a rabbitmq subscription. I'd ideally like to move that code into the plugin class (avoiding the global var), so I can have updates trigger methods in the class.
<bosma> I put it in the initialize but I'm pretty sure it wasn't working there
<bosma> what would be a nice place to put that code to get rid of global vars and make it have access to plugin methods?
<bosma> scratch that it does work in initialize. guess was another bug.
<dominikh> bosma: if you overwrite a plugin's initialize, you have to call super.
<dominikh> otherwise the plugin won't work correctly
<bosma> yeah I do that. I think there was something wrong with my code unrelated when I tested.
<dominikh> alright
<bosma> Everything all good
<bosma> ##forextraders 500x eurusd bot :D
<dominikh> sorry, not into trading :P
<bosma> wish the ruby bindings worked for zeromq on windows
<bosma> overheads a bit much but rabbitmq seems to have some good features
<dominikh> could always host it on one of the many systems better suited for it than Windows ;)
<bosma> :)
<bosma> yeah I value gaming too much. should get a linux dev environment on a vm
<bosma> had freebsd as my desktop for awhile would love to go back
<dominikh> had you picked linux, you could at least play *some* popular games
<bosma> you have no idea the amount of things I've been working on where every solution boils down to get off windows haha
<bosma> na directx / nvid drivers so much better. vm is solution
<bosma> thanks for the great framework btw
<dominikh> no problem
<bosma> oo you use void?
<bosma> was recommended
<dominikh> I do, yes
<dominikh> I'm a package maintainer for Void, even.
<bosma> should have a bitcoin address donation ;)
<bosma> awesome. I'll try it out
postmodern has quit [Quit: Leaving]
sarkyniin has joined #cinch
bosma is now known as FakOlly
FakOlly is now known as TEAMJON
TEAMJON is now known as TEAMVARYSTYRION
Dwarf has quit [Ping timeout: 265 seconds]
Paradox has quit [Ping timeout: 265 seconds]
Paradox has joined #cinch
Dwarf has joined #cinch
sarkyniin has quit [Ping timeout: 250 seconds]
sarkyniin has joined #cinch
eebs has joined #cinch
sarkyniin has quit [Quit: Quit]
<awkisopen> so here's something that's going to sound like a pointless question: is there a way to accept the risk and force a plugin hook to run on the main thread?
<awkisopen> I realize this is a risky thing to do and goes against the design, but there is a strange use case
<awkisopen> when someone identifies to nickserv on any server, there's a quick leave-join that technically happens one after the other, but the information reaches the client at about the same time
<awkisopen> if you're trying to keep track of user state, it's a toss-up if the "changing host" leave happens first or the rejoin with the new hostname happens first. in general it tends to go in the right order, but there's the possibility it does not
<awkisopen> for myself I'm probably going to just keep track of recent leaves and joins and compare timestamps and make a few assumptions accordingly
<dominikh> no, that's one of the flaws of Cinch; there's no guaranteed way to determine order between messages. the message's timestamp should be "good enough"
<dominikh> actually, let me check…
<awkisopen> also, thank you again for the super quick patch yesterday, haha
<awkisopen> that's the second time I've come in here, said something was a bit off, and it was fixed within the hour
<dominikh> what was the first one?
<awkisopen> authname wasn't returning the right value on snoonet because the order of information from WHOIS wasn't in the order cinch expected
<dominikh> ah. always those WHOIS
<awkisopen> tricky bastards
<dominikh> anyway, Message#time is your best bet to get order, I think its precision should be nanoseconds (but probably depends on the OS)
<awkisopen> it's a linux server so I don't doubt it'll be nanoseconds
<dominikh> there's no way to disable threading. Cinch's core doesn't technically know about plugins to begin with, they're all individual handlers. and there's no (public) way of forcing a handler to run on the main thread
<dominikh> hm, there might be a hack
<dominikh> 1 sec
<awkisopen> yeah the only way I could ever think of it working is if you could specify a mutex when hooking events
<dominikh> hm no, even the hack would still be racy. one could have a per-plugin mutex, but that still doesn't mean that messages arive in the correct order
<dominikh> arrive, either
<awkisopen> dang
<awkisopen> the time comparison is a good one, now I'm just trying to work out /where/ I'd do the comparison. I guess both my join and leave methods could check for any other recent joins/leaves
<dominikh> yeah
<dominikh> make sure to have a mutex around the data structure you use for storing joins/leaves
<awkisopen> if I assigned both :leaving and :join to the same method, and put that method's contents in a mutex, would that still be racy? (I don't know enough about cinch's design to answer that myself)
<dominikh> yes, it would be. for each incoming message, we parse it and find the handler(s) to execute. we then spawn a thread and execute the handler.
<awkisopen> basically depends on how the hooks are actually called
<awkisopen> gotcha
<dominikh> once the threads are created, you don't know in which order they'll be scheduled
<dominikh> technically, I could add a per-handler mutex/queue, but that'd be a new feature, and I'm not sure I want to add new features to Cinch at this point
<awkisopen> I hear that
<dominikh> also… it wouldn't help exactly; I don't think a single handler can listen to multiple events
<dominikh> and two separate handlers wouldn't have the mutex again
<dominikh> oh, actually you can, hm.
<dominikh> okay, no, you can't. yeah, it'd be changing too much at this point. sorry.
<awkisopen> I think I figured out a solution for myself anyway: keep track of how many joins or leaves each user has, if they have an equal number or greater or leaves than joins, they've left; otherwise they're still on. that should work even if things get scheduled wonkily
<dominikh> well
<dominikh> I hope that if you restart the bot and it joins a channel full of people, it'll know that those people joined at some point
<dominikh> also, enjoy the race while you process the initial user list and people join/leave at the same time...
<awkisopen> I only have to track them when they've started interacting with the bot in a particular way, which means they have to be on in any case
<dominikh> why are you listening to joins and parts, anyway?
<dominikh> ah, the "knowing the host of someone who left" stuff, I remember
<awkisopen> yeah. each user has some data associated with them, and they're authenticated based on their authname or, failing that, their host
<awkisopen> obviously hosts are only good for temporary storage and they're encouraged to register with nickserv
<dominikh> and why is their authentication relevant once they left?
<dominikh> what is special about authenticated people leaving?
<awkisopen> it's a writing channel, and authenticated people can take part in something called a "word sprint," where they write against a timer (time is kept by the bot). if someone leaves, and they were the last person in the sprint, the sprint auto-closes after a minute, to avoid a dead sprint taking space in the channel
<awkisopen> there's also the matter of waiting for people to finalize their wordcounts at the end of the sprint, and the bot should not wait for someone who is no longer there to perform an action they cannot
<awkisopen> I could have it ignore both of these things but it leads to a messy channel
<dominikh> ah, okay
<awkisopen> anyway, the bot considers two nicks with the same host or same authname to be the same person, for convenience's sake
postmodern has joined #cinch
sarkyniin has joined #cinch
TEAMVARYSTYRION is now known as bosnia
djbkd has joined #cinch
postmodern has quit [Quit: Leaving]
postmodern has joined #cinch
eebs has quit [Quit: Leaving.]
bosnia is now known as MAKOHYPE
sarkyniin has quit [Quit: Quit]