dominikh changed the topic of #cinch to: The IRC Framework | Latest version: Cinch 2.1.0
<CM-Punk> I would have no clue how to do that
<leftylink> save Time.now.to_i in an instance variable when a message is sent. When you would send a message, compare Time.now.to_i to stored time. If difference too small, don't send
<leftylink> actually, wow, you don't even need the .to_i because Time values support the - operator
<leftylink> that is a fun fact that I did not know until I tried it just now
<CM-Punk> Oh
<CM-Punk> That would be fun
<CM-Punk> Do you have an example I could work off of leftylink? I learn by studying stuff like that
xeviox is now known as xeviox|afk
<leftylink> CM-Punk: so when I was thinking of examples to show, the most natural example that came to my mind was a bot that I worked on - https://github.com/caitlin/cinch-coupgame/blob/master/lib/cinch/plugins/coup_game.rb (see how invite works)
<leftylink> HOWEVER, that is not as direct as the approach I gave
<leftylink> since it's storing its state in a Game object as just a boolean
<leftylink> and then starts a one-shot Timer to reset the boolean flag
<leftylink> that *is* a possible approach you could take, and it is perfectly valid. so consider that a possible alternative to the approach I outlined above
<CM-Punk> Okay
<CM-Punk> Thank you so much
<leftylink> my default approach (the way I immediately think of how to implement it if i were asked to) would be the way I described (store the time a message was last sent)
<leftylink> but I didn't have an exapmle for that immediately handy
<leftylink> and I know the example I gave ia bit piece of code, but again it's all I had, my apologies for not being able to provide something smaller
<leftylink> I guess an advantage of this is you hvae the assurance that this code is actually in production and is currently known to be working well
hephaestus_rg has joined #cinch
<CM-Punk> Yeah leftylink, thanks! :D
hephaestus_rg has quit [Ping timeout: 252 seconds]
postmodern has joined #cinch
cadence has quit [Ping timeout: 264 seconds]
postmodern has quit [Quit: Leaving]
kludge` has quit [Ping timeout: 264 seconds]
kludge` has joined #cinch
xeviox|afk is now known as xeviox
xeviox is now known as xeviox|afk
geopet has joined #cinch
<CM-Punk> leftylink, I have to say...this code is impressive, and being a n00b to ruby I feel lost....
<CM-Punk> Like...
<CM-Punk> "game.reset_invitation" I have no idea how the code knows what to do what that
<CM-Punk> I'm self learning this all...
<CM-Punk> XD
<CM-Punk> s/what/with
<CM-Punk> https://github.com/Namasteh/Eve-Bot/blob/master/lib/eve/plugins/greeting.rb That's my greeting plugin, the one that I need to put a timer on to stop it from flooding a channel on NetSplit rejoins
<CM-Punk> Could one do like
<CM-Punk> greet = hello(m) Timer(4, shots:1) do greet.reset_greeting
<CM-Punk> And that would work?
<nickrw> CM-Punk: I do ratelimiting with this helper method for one of my plugins: https://github.com/nickrw/TWGbot/blob/master/lib/twg/helpers.rb#L110
<CM-Punk> Oh my god
<CM-Punk> Okay
<CM-Punk> I get that
<CM-Punk> Thank you nickrw
<nickrw> np
<nickrw> might be worth wrapping it in a synchronize block
<CM-Punk> Pardon? I don't understand nickrw, what is a synchronize block?
<CM-Punk> D:
<nickrw> should make it more thread-safe
<nickrw> it's reasonably important for the use-case of something triggering on a join as netsplits could make the code trigger multiple threads at the same time, each wanting to check the last ratelimit timestamp
<CM-Punk> Ah yes
<CM-Punk> More sane than crashing the threads
txdv has quit [Read error: Connection reset by peer]
txdv has joined #cinch
<nickrw> well, they wouldn't crash, you'd just see unexpected results
<CM-Punk> Ah
UberDragon has joined #cinch
<CM-Punk> https://github.com/Namasteh/Eve-Bot/blob/master/lib/eve/plugins/priv_chan_cp.rb#L321 Can anyone tell me why this only changes to the first word of the topic I'm trying to set?
<leftylink> because no colon
<leftylink> doesn't Channel have a #topic= or something that would help with this (putting the colon in, etc)?
v0n has quit [Ping timeout: 240 seconds]
v0n has joined #cinch
geopet has quit []
geopet has joined #cinch
<CM-Punk> How do I call that into my plugin nickrw?
<CM-Punk> Like Channel(channel).topic?
<CM-Punk> Hold on
<CM-Punk> I might have been mistaken about something
<nickrw> Channel("#foo").topic = "this is my new topic"
<nickrw> you use Channel(channel) a few times in that code, so probably worth assigning it to a var
<CM-Punk> I got it to work!
<nickrw> :)
<CM-Punk> Yeah, it's stuff like what you just said that I am thinking I might have to do but I'm just learning how to work all that
<CM-Punk> Like
<CM-Punk> https://github.com/Namasteh/Eve-Bot/blob/master/lib/eve/plugins/plugin_management.rb In my plugins like this I am certain that the initialize and reload are redundant in some way but the script won't load new masters without restarting without the reload
<CM-Punk> Does cinches Channel object have a topic string? To fetch the current topic?
<CM-Punk> Found it
<nickrw> CM-Punk: yeah looking at that file you can remove lines 21-25 and just replace them with 'reload'
<CM-Punk> So keep def initialize super end
<CM-Punk> ?
<nickrw> yes
<dominikh> if all you're doing is call super, why overwrite the method at all?
<nickrw> it's not just calling super
<CM-Punk> It's calling a yaml file
<leftylink> but reload is being called before all other functions. is it necessary to put it in the ctor?
<nickrw> ah true
<nickrw> I hadn't noticed it was in all of them
<CM-Punk> So removed initialize alltogether?
<nickrw> yes
<CM-Punk> Ok
<leftylink> I also see absolutely no references to @storage
<leftylink> so I don't see the need for reload at all!
<CM-Punk> Pardon?
<CM-Punk> Uh
<CM-Punk> Should I probably just put the reload in that helper instead?
<CM-Punk> Have it call at the beginning of the fuction?
<leftylink> oh, I see. it's used in check_master. Well, doesn't it seem logical that the code should go there? instead of in plugin_management?
<CM-Punk> Ok, so put the reload function in check_master and have check_master call reload before doing anything else
<CM-Punk> Same results, less code?
<nickrw> does any other plugin use the same check_master helper?
<CM-Punk> Yeah, tons
<nickrw> then yes, put the reload logic in there
<CM-Punk> Awesome
<CM-Punk> Then I can remove intialize, right?
<nickrw> yeah
<CM-Punk> Awesome.
<CM-Punk> Thanks.
postmodern has joined #cinch
geopet has quit []
v0n has quit [Ping timeout: 240 seconds]
awkisopen has quit [Ping timeout: 265 seconds]