nickvanw / ircx

Basic callback-driven Go IRC bot
Apache License 2.0
37 stars 13 forks source link

Should redo initialization #5

Closed flowchartsman closed 9 years ago

flowchartsman commented 9 years ago

When I was adding TLS support, I noticed something a bit odd about bot initialization. Specifically NewBot(f ...func(*Bot)) *Bot which, towards the end of the function, loops over any funcs it's received and runs them on the bot. This smacks of Rob Pike's approach to providing options to initialization, but it's never really used for anything (as only one function is ever passed), and it doesn't lend itself to composition particularly well, because Classic and WithLogin return fully-fledged bots instead of their own mutator functions.

I propose that the library either adopt a configuration style of initialization or, if you prefer to keep the mutator style intact, a series of non-overlapping mutator functions that functions like Classic composite together and pass to NewBot

I'd be willing to work on this.

nickvanw commented 9 years ago

Agreed completely, I'm inclined to make a series of mutator functions along with a set of required parameters. The required parameters would make it possible to make a functioning Bot, and the optional params for things such as Login and TLS could mutate additional, optional, functionality.