jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 272 seconds]
rocx has joined #crystal-lang
<ChrisVincent[m]> Are optional arguments not allowed in a macro?
alexherbo2 has joined #crystal-lang
DTZUZU has quit [Ping timeout: 256 seconds]
deavmi has quit [Ping timeout: 258 seconds]
DTZUZU has joined #crystal-lang
sagax has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
oddp has joined #crystal-lang
deavmi has joined #crystal-lang
_whitelogger has joined #crystal-lang
Elouin has quit [Read error: Connection reset by peer]
Elouin5 has joined #crystal-lang
Elouin5 is now known as Elouin
<FromGitter> <asterite> I think they are
<raz> https://crystal-lang.org/api/0.35.1/HTTP/Params.html#[]=(name,value)-instance-method
<raz> hmm, this feels wrong. shouldn't it rather clear the array and set the new value as the only one?
<raz> (as that seems to be a more common use-case. i wonder why/when one would ever want to overwrite the first value)
<FromGitter> <asterite> yeah, I think it's wrong. Please submit a bug report
<raz> done, my good deed for the day
<FromGitter> <RespiteSage> Ooh, a working serializer.
<FromGitter> <Blacksmoke16> :)
alexherbo2 has quit [Ping timeout: 272 seconds]
<FromGitter> <RespiteSage> I've looked a little bit into templating languages (as I've mentioned before, I'm not a web dev, so I'm unfamiliar with them), but I'm having trouble finding something useful for templating program data files (as opposed to markup). I'm trying to do something similar to `What color is this $animal? This is a $color $animal!` where each `$value` would be replaced randomly from lists. Preferably, I'd like the
<FromGitter> ... templates, the names of the lists, and the contents of the lists to be modifiable by a user (i.e. without having to recompile the program), though there will of course need to be an entry point somewhere (i.e. "this list of templates is what you start with; pick randomly from those"). Is a templating language what I need? ... [https://gitter.im/crystal-lang/crystal?at=5f0b52ef7a4e99049e07d5da]
<FromGitter> <RespiteSage> (For context, I want to modify Discryb (https://github.com/RespiteSage/discryb) to allow user-created data instead of relying on an outside API.
<FromGitter> <RespiteSage> ("User" meaning the person running the executable.)
rocx has quit [Quit: 👏 developers 👏 developers 👏 developers 👏 developers]
<FromGitter> <Blacksmoke16> a template can also just be a string
<FromGitter> <Blacksmoke16> then could just have the value be `options.sample`
<FromGitter> <RespiteSage> Thanks, I'll try that.
<straight-shoota> RespiteSage, I don't quite follow, what exactly you're asking for
<straight-shoota> If you just want to replace `$foo` with the value of `foo` looked up from a hash or similar, you don't really need a template engine for that.
<FromGitter> <Blacksmoke16> `"#{options.sample}"`
<straight-shoota> `String#gsub` would be perfectly fine for this
<straight-shoota> Only if you may need more than that, you would really need a template engine
<FromGitter> <RespiteSage> What I'm looking for is a way to allow the data (plaintext, editable after compilation) to be something like ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ or even to allow multiple levels of substitution. Actually, though, I think I have a good idea of how to implement this. I probably don't need templating, like you say. [https://gitter.im/crystal-lang/crystal?at=5f0b5818c7d15f7d0f8b3d98]
<FromGitter> <RespiteSage> To be clear, example compliments generated from the above data file could be "Your face is just like a green bottlenose dolphin." or "It's really cool how harrowed you are."
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> and i assume the possible options are static?
<FromGitter> <Blacksmoke16> or do you expect for someone to be able to dynamically add their own compliment with a new option array?
<FromGitter> <asterite> to me it looks like that's the program, not a library. Just load the YAML file into a Hash(String, String), then using gsub with a regex should be enough.
<FromGitter> <RespiteSage> @Blacksmoke16 The possible options are supposed to be configurable at runtime by the user (i.e. your second option). I think that @straight-shoota and @asterite are right; I was just overthinking it, and I can just load it into a hash.
<FromGitter> <Blacksmoke16> 👍
<FromGitter> ... I want anybody who uses it to have an easy time customizing what kinds of compliments (and eventually insults, observations, etc.) they want.
<FromGitter> <RespiteSage> The basic problem this is solving is that I meant for this bot to be a silly and positive bot to add to a Discord I'm in, and some of the compliments from the API I'm using (https://complimentr.com/) can be just a bit more focused on certain body parts (for instance) than I want. So I want it configurable for me, but also the whole purpose of having an open-source project is so other people can use it, and
alexherbo2 has quit [Ping timeout: 272 seconds]
rocx has joined #crystal-lang
oddp has quit [Ping timeout: 260 seconds]