adam12 changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.2.2, 3.1.4, 3.0.6, 2.7.8: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://t.ly/9ua4 | Logs: https://libera.irclog.whitequark.org/ruby/
Al2O3 has joined #ruby
gemmaro has quit [Remote host closed the connection]
Sankalp has joined #ruby
Ignorand has quit [Ping timeout: 246 seconds]
lunks has joined #ruby
Ignorand has joined #ruby
ignorand_ has joined #ruby
Ignorand has quit [Ping timeout: 254 seconds]
reset has quit [Quit: reset]
Dooky has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ignorand__ has joined #ruby
ignorand_ has quit [Ping timeout: 252 seconds]
reset has joined #ruby
ele_mesmo has joined #ruby
ele_mesmo has quit [Client Quit]
<mooff> isene: i've started to put `require "json"` etc as the first line inside a module that requires it
<mooff> i think there is license to do that if you want
<mooff> that way the lib doesn't assume you're going to use it with the stdlib "socket"s
<mooff> for instance, mruby doesn't offer "socket" (at least not built-in)
<mooff> but you could still write an mruby IRC bot using standard out and standard in
defectiverobot has joined #ruby
agent_white has joined #ruby
ignorand__ has quit [Ping timeout: 255 seconds]
ignorand__ has joined #ruby
defectiverobot has quit [Remote host closed the connection]
<mooff> require() itself already contains the "unless feature already loaded"
<mooff> the array used by MRI and others to store the already required files is called $LOADED_FEATURES
ignorand__ has quit [Ping timeout: 255 seconds]
<mooff> it should be safe and quick to call again and again
gemmaro has joined #ruby
defectiverobot has joined #ruby
defectiverobot has quit [Remote host closed the connection]
bambanxx has joined #ruby
Sheilong has quit [Quit: Connection closed for inactivity]
mooff has quit [Remote host closed the connection]
mooff has joined #ruby
<ox1eef_> That depends entirely on the context. $LOADED_FEATURES would be huge in a Rails app.
<ox1eef_> Worth keeping in mind that rubygems monkeypatches Kernel#require too. So the C implementation exists underneath that.
coastm54 has joined #ruby
<ox1eef_> 0x1eef [0x1eef] % cat foo.rb
<ox1eef_> require 'rake'
<ox1eef_> puts method(:require).source_location
<ox1eef_> 0x1eef [0x1eef] % ruby foo.rb
<ox1eef_> <internal:/usr/local/lib/ruby/3.1/rubygems/core_ext/kernel_require.rb>
<ox1eef_> 36
<mooff> eek, yeah. that looks like the normal stdlib require there ^, but i get your point
<mooff> in a Rails app it could be problematic. it's a tool in the toolbelt, though
grenierm has joined #ruby
<ox1eef_> Yeah, it may be that the overhead doesn't matter. As a rule of thumb I would use require_relative to require files within my lib, and not call require in hot codepaths.
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
Thiago66 has joined #ruby
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 240 seconds]
desnudopenguino1 is now known as desnudopenguino
<gr33n7007h> mooff: I just gave you your first ⭐
jhass has quit [Ping timeout: 248 seconds]
jhass has joined #ruby
coastm54 has quit [Remote host closed the connection]
<mooff> gr33n7007h: thanks ⭐
coastm54 has joined #ruby
<mooff> hope the docs are clear
coastm54 has quit [Ping timeout: 240 seconds]
roadie has joined #ruby
<gr33n7007h> mooff: It's a nicely written, clean and concise IRCv3 framework. The documentation seem clear to me from what I've briefly read, so, I'm gonna have a closer look at it later 😃
<mooff> cheers 🙂
<mooff> i made a very fun bot with it. commands are run by admins as Ruby code
<mooff> it can show its own source code using a combo of method_source, a popular syntax highligher, and piping through an ANSI-to-IRC color converter
<gr33n7007h> mooff: 🤖 Neat!
<mooff> i added a unary ~ method to Symbols, that returns method(self)
<mooff> then made #inspect on Method and UnboundMethod .. include the method's source code 🤓
<mooff> so you can ". ~:foo" to see #foo's source code
<mooff> the library was extracted from the bot and made a good base for it
<mooff> if you know Ruby and know IRC, you should be able to grok a good library instantly
<mooff> i found that difficult with cinch, which also unfortunately fell out of maintenance
<gr33n7007h> Indeed! Yeah, cinch I know well but Dominik unfortunetly drifted over to Go, so maintainance basically came to an end.
<gr33n7007h> bbl, going for some breakfast 👍
infinity_fye has joined #ruby
infinityfye has quit [Ping timeout: 252 seconds]
mretka has quit [Ping timeout: 244 seconds]
mretka has joined #ruby
<mooff> Dominik is an asset to any community. I'm pleased he's been looking at Go!
<mooff> IIRC can also be used to implement "pseudoservers". that is, you can use it to implement an S2S protocol, like Unreal's commands
<mooff> cinch was written when there was a certain DSL fever, if i recall :D
teclator has joined #ruby
moldorcoder7 has quit [Ping timeout: 252 seconds]
tomtmym has joined #ruby
tomtmym has quit [Changing host]
tomtmym has joined #ruby
Pixi has quit [Ping timeout: 246 seconds]
hightower3 has quit [Ping timeout: 250 seconds]
Pixi has joined #ruby
shokohsc3 has joined #ruby
shokohsc has quit [Ping timeout: 246 seconds]
shokohsc3 is now known as shokohsc
_ht has joined #ruby
jvalleroy has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
jvalleroy has joined #ruby
lunks has quit [Read error: Connection reset by peer]
reset has quit [Quit: reset]
lunks has joined #ruby
hightower2 has joined #ruby
egality has quit [Remote host closed the connection]
<isene> mooff: thanks for the input 👍
<mooff> live ur best life isene
crespire has joined #ruby
crespire1 has quit [Ping timeout: 250 seconds]
<mooff> 🤓
crespire has quit [Ping timeout: 240 seconds]
<isene> That I'm doing 🤗
crespire has joined #ruby
Linux_Kerio has joined #ruby
Evertonlc has joined #ruby
Evertonlc has quit [Client Quit]
<isene> How can I tell the user that there is a newer gem version available at RubyGems of my program?
<isene> Specifically, when the user presses 'v', the program displays the version and should also tell the user that she should update the gem since there is a newer version over at rubygems.org
<isene> found it nm
agent_white has quit [Quit: leaving]
nakilon has joined #ruby
grenierm has quit [Ping timeout: 245 seconds]
Pixi` has joined #ruby
Pixi has quit [Ping timeout: 276 seconds]
Dooky has joined #ruby
gr33n7007h has quit [Ping timeout: 264 seconds]
roadie has quit [Quit: ERC 5.5 (IRC client for GNU Emacs 29.0.90)]
teclator has quit [Ping timeout: 248 seconds]
gr33n7007h has joined #ruby
Pixi` has quit [Ping timeout: 256 seconds]
Al2O3 has quit [Quit: I'm quitting, thanks for all the sharks.]
infinity_fye has quit [Quit: Leaving]
desnudopenguino1 has joined #ruby
desnudopenguino has quit [Ping timeout: 248 seconds]
desnudopenguino1 is now known as desnudopenguino
mahlon has quit [Ping timeout: 265 seconds]
gr33n7007h has quit [Quit: WeeChat 3.8]
___nick___ has joined #ruby
cornett_ has joined #ruby
egality has joined #ruby
tomtmym_ has joined #ruby
cornett has quit [Ping timeout: 320 seconds]
nakilon has quit [Quit: Client closed]
tomtmym has quit [Ping timeout: 305 seconds]
micro has quit [Ping timeout: 305 seconds]
roadie has joined #ruby
mahlon has joined #ruby
micro has joined #ruby
gr33n7007h has joined #ruby
Linux_Kerio has quit [Quit: Konversation terminated!]
Linux_Kerio has joined #ruby
Pixi has joined #ruby
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
infinityfye has joined #ruby
moldorcoder7 has joined #ruby
___nick___ has joined #ruby
hightower2 has quit [Ping timeout: 246 seconds]
moldorcoder7 has quit [Ping timeout: 252 seconds]
hightower2 has joined #ruby
llua has quit [Ping timeout: 240 seconds]
llua has joined #ruby
TomyLobo has joined #ruby
Ignorand has joined #ruby
___nick___ has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
defectiverobot has joined #ruby
TomyLobo has quit [Read error: Connection reset by peer]
defectiverobot has quit [Remote host closed the connection]
hightower2 has quit [Ping timeout: 255 seconds]
gemmaro has quit [Remote host closed the connection]
defectiverobot has joined #ruby
defectiverobot has quit [Remote host closed the connection]
Rounin has joined #ruby
Rounin has quit [Changing host]
Rounin has joined #ruby
Linux_Kerio has quit [Quit: Konversation terminated!]
Linux_Kerio has joined #ruby
Ignorand has quit [Ping timeout: 255 seconds]
moldorcoder7 has joined #ruby
<ox1eef_> Re-reading the backlog, in regards to "that looks like a normal stdlib require" - I don't think there is such a thing anymore. rake is a gem. And so is all of the stdlib: stdgems.org
graywolf has joined #ruby
reset has joined #ruby
<weaksauce> mooff what irc library is it?
<petru> mooff: I forked cinch and got it working with Ruby 3, fwiw
<ox1eef_> Worth keeping in mind the next time someone asks for a IRC bot lib.
<weaksauce> nice
<weaksauce> pretty nice library
<ox1eef_> !guys2
<ox1eef_> ?guys2
<ruby[bot]> it doesn’t matter if it’s "normal"/gender neutral to say "guys" in your idiolect. "You guys" to refer to a mixed group is erasure. All we ask from you is to be a decent channel member and respect that. If you want to further discuss this, join #ruby-offtopic.
<ox1eef_> Barf
<petru> O_o
<ox1eef_> ?next
<ruby[bot]> Next question, please!
<ox1eef_> But that's not treating people like dirt.
bambanxx has joined #ruby
<adam12> petru: New irc lib looks greast. Nicely done.
<weaksauce> i think it's mooff's bot lib adam12
<adam12> weaksauce: Oof. I guess I didn't follow along as well as I thought. Thanks for clarifying.
<Rounin> ?seriously
<ruby[bot]> Rounin: I don't know anything about seriously
<Rounin> You made a bit just to bikeshed and complain at people about made-up problems?
<Rounin> We should start a #racism_and_sexism to discuss Ruby
johnjaye has joined #ruby
shokohsc2 has joined #ruby
shokohsc has quit [Ping timeout: 246 seconds]
shokohsc2 is now known as shokohsc
___nick___ has quit [Ping timeout: 276 seconds]
otisolsen70 has joined #ruby
hightower2 has joined #ruby
leandroico has joined #ruby
Dooky_ has joined #ruby
Dooky has quit [Ping timeout: 276 seconds]
reset has quit [*.net *.split]
Rounin has quit [*.net *.split]
Linux_Kerio has quit [*.net *.split]
moldorcoder7 has quit [*.net *.split]
micro has quit [*.net *.split]
aindilis_ has quit [*.net *.split]
micro has joined #ruby
aindilis has joined #ruby
Rounin has joined #ruby
Rounin has joined #ruby
Rounin has quit [Changing host]
reset has joined #ruby
moldorcoder7 has joined #ruby
Linux_Kerio has joined #ruby
juliana has joined #ruby
juliana has quit [Client Quit]
_ht has quit [Remote host closed the connection]
juliana has joined #ruby
juliana has quit [Client Quit]
juliana has joined #ruby
juliana has quit [Client Quit]
juliana has joined #ruby
juliana has quit [Client Quit]
juliana has joined #ruby
juliana has quit [Client Quit]
juliana has joined #ruby
juliana has quit [Client Quit]
<weaksauce> mooff is the bot going to handle flood protection?
roadie has quit [Ping timeout: 248 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 248 seconds]
infinityfye has quit [Read error: Connection reset by peer]
<mooff> weaksauce: the lib doesn't have anything specifically built in. what kind of protection do you need?
<weaksauce> mooff most irc bots i've seen will have a rate limiter so they don't spam the feed if it tries to send too many messages
c10l has quit [Ping timeout: 276 seconds]
<mooff> i figure that most of the time it's either a social rather than rate limiting problem (e.g. if someone calls a command too often, it's only doing their biding)
roadie has joined #ruby
<weaksauce> i guess you aren't making a general purpose library then?
<mooff> or it's application specific.. if a command has too much output, a framework can only slow it down, or drop outgoing messages arbitrarily
<weaksauce> yeah it's really to avoid getting the bot kicked
<weaksauce> say you have a news thing that dumps a feed into a channel and a lot of news gets dropped and the bot dumps all of it at once it will get kicked
<ox1eef_> Cinch has support for that built-in but I can't remember the specifics of how it works.
<mooff> weaksauce: in that case, it's better for the output (e.g. up to 10 messages) to happen all at once, without much lag
<mooff> but say it ends up having 50 messages to print. what should happen when it goes over those 10?
<mooff> it calls for adjustment in the !news command, right?
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
otisolsen70 has quit [Quit: Leaving]
<weaksauce> usually it just delays the queue
roadie has quit [Ping timeout: 248 seconds]
<weaksauce> i think the main reason irc kicks for it is to prevent ddos kinda things
<mooff> something like that could work
<mooff> imo the ddos level thing is better handled by the network
<ox1eef_> is your bot also threaded ?
<mooff> yes, i've used it primarily with threads, even running an IRB shell on the main thread
<mooff> i wouldn't be against the library offering a command to run your bot interactively - with a console GUI
bambanxx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
c10l has joined #ruby
tomtmym_ has quit [Quit: Gone.]
<ox1eef_> All these options look relevant to handling flooding in Cinch: max_messages, messages_per_second, server_queue_size, message_split_start, message_split_end
shokohsc has quit [Ping timeout: 276 seconds]
shokohsc has joined #ruby
<mooff> let me look those up
<mooff> right i see. yeah, those are unimplemented at the moment
<mooff> but it's designed to have clear interface points, with overriding for things like this supported or encouraged
<mooff> for example, including IIRC::IRCv3::Parsing gives you a parse() that supports IRCv3 messages
Ignorand has joined #ruby
<ox1eef_> What happens when you have two modules overriding the same method ? Should super always be called ?
<mooff> if you're transforming the work of the parent method, you'll naturally call super
<mooff> sometimes, it isn't needed
delimite1 has joined #ruby
<ox1eef_> Nice. Mixins are a nice approach.
<weaksauce> oh dang octotree functions are getting added to github itself
roadie has joined #ruby
<mooff> yeah. it's a mixin kit ultimately
<ox1eef_> I guess if you want to create a module that takes options, you could implement something like: def Mod.mixin(foo:); Module.new { @foo = foo; ... }; end; include Mod.mixin(foo: "bar").
<ox1eef_> Such as messages_per_second, etc.
<mooff> ha, nice! could you even do Module.new(Foo) or Module.new(self) ?
c10l has quit [Ping timeout: 252 seconds]
<mooff> for options i'd gone with the approach where you override a method to return your preference
<mooff> e.g. def autojoin_channels() = ["#one", "#two"]
<ox1eef_> Yeah that makes sense, one advsntage of passing options is that they can be contextualized to a given Module.
<ox1eef_> You could even encapsulate the options to just that module by keeping them as locals and using define_method(...) { }.
<mooff> only trouble is that could become less introspectable
<ox1eef_> True
roadie has quit [Ping timeout: 248 seconds]
<mooff> because the source of truth for a something becomes a hidden variable in a closure
<mooff> like the JS factory pattern - debugging or plumbing with those often got me frustrated as you can't even look into the data using the console
<mooff> never mind change it or monkey patch behaviour
<ox1eef_> I love that about JS :)
<mooff> FailFish.jpg
<mooff> heheheh
<ox1eef_> When I first got into JS (coming from Ruby) I expected a private keyword to encapsulate state, and eventually realized everything is private by default unless you expose it via 'this' - in the context of function constructors.
<mooff> one thing i liked was a having a "!cmd foo <ruby code>" command..
<mooff> storing the strings in Redis, then eval() ing and printing the result when you !foo
<ox1eef_> I seem to remember something like that.
<mooff> !cmd hi %w(Hey! Hello Howareya).sample
Ignorand has quit [Ping timeout: 276 seconds]
<weaksauce> this bot does a queue that implements a basic flood control
<mooff> !outlaw big factory constructors with closure scoping :P
<weaksauce> it's old and kinda terse but yeah
<ox1eef_> lol
<mooff> cool weaksauce. i liked reading isaac when brainstorming for my lib
<weaksauce> i was thinking of making isaacish but redoing it in async but then decided that was too much work
<weaksauce> i do think the unlocking the queue after a ping or pong is a good approach to do it without a busywait
<mooff> maybe you could use leverage my building blocks to have a go
<mooff> ideally they're agnostic to thread / fiber / async / whatever dispatch etc
<mooff> for outgoing queues, my feeling is to let the network handle it atm
<mooff> they already handle e.g. splitting long messages, brute rate limits, flood protection, etc
<weaksauce> yeah perhaps it's fine nowadays
<weaksauce> most ircbots i've seen are pretty old
<ox1eef_> Just like the people who use IRC
<mooff> heyy
<weaksauce> i will say shame on them for metaprogramming when it needn't be metaprogrammed
<weaksauce> saved yourself three methods you could have copy pasted
<mooff> can we honestly say... that we didn't metaprogram when it needn't be metaprogrammed.. in 2011 🤓
<weaksauce> haha ok fair
<mooff> let those without sin cast the first stone!! 😄
<mooff> did define_method come in Ruby 1.9?
<mooff> i remember that eval() like that fell out of fashion around some point
leandroico has quit [Ping timeout: 252 seconds]
c10l has joined #ruby
<ox1eef_> I believe that has more to do with performance. It is suppose to be faster to eval a string rather than use the block form. Don't know if it still holds true. And some will say don't define methods at runtime at all, because it busts a method cache but features exist to be used so not sure about following such advice.
Ignorand has joined #ruby
<mooff> yeah, and there are still things you can only do with eval() i guess
roadie has joined #ruby
<ox1eef_> Binding#eval is super powerful.
<mooff> oh yeah. gorgeous feature..
<mooff> e.g. to eval in a scope with no local variables in a REPL: def scope_with_no_locals() = binding
<mooff> scope_with_no_locals.eval(user_string)
<ox1eef_> I have found its ability to close over locals esp useful, you can create a binding in one method, pass it to another, and then alter the locals of the first method
roadie has quit [Ping timeout: 248 seconds]
<ox1eef_> Variation of that done here, with execution suspended halfway through th emethod call: https://github.com/0x1eef/trip.rb#concurrency
graywolf has quit [Ping timeout: 250 seconds]
<mooff> nice, I never knew about TracePoint or rescue *list_of_exceptions
Linux_Kerio has quit [Ping timeout: 246 seconds]
<ox1eef_> rescue Pry::RescuableException => e
<mooff> cool!
yosafbridge has quit [Quit: Leaving]