Closed flowchartsman closed 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.
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, becauseClassic
andWithLogin
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 toNewBot
I'd be willing to work on this.