Skip to content

Allow modules to define collections of responders#67

Open
rjanja wants to merge 1 commit into
hedwig-im:masterfrom
labzero:responder-collections
Open

Allow modules to define collections of responders#67
rjanja wants to merge 1 commit into
hedwig-im:masterfrom
labzero:responder-collections

Conversation

@rjanja

@rjanja rjanja commented Mar 16, 2017

Copy link
Copy Markdown

In some cases it is convenient to define a collection of responders outside of the bot's configuration file, and then to reference that collection as a list of responders to load with the bot.

Ex.:

Instead of:

config :testbot, Testbot.Robot,
  responders: [
    {Hedwig.Responders.Help, []},
    {Hedwig.Responders.Ping, []},
    {HedwigGithub.Responder, []},
    {HedwigPlusPlus.Responder, []},
    {HedwigSimpleResponders.BeerMe, []},
    {HedwigSimpleResponders.Echo, []},
    {HedwigSimpleResponders.Fishpun, []},
    {HedwigSimpleResponders.Flip, []},
    {HedwigSimpleResponders.Manatee, []},
    {HedwigSimpleResponders.PugMe, []},
    {HedwigSimpleResponders.Shingy, []},
    {HedwigSimpleResponders.ShipIt, []},
    {HedwigSimpleResponders.Slime, []},
    {HedwigSimpleResponders.Slogan, []},
    {HedwigSimpleResponders.Stallman, []},
    {HedwigSimpleResponders.Time, []},
    {HedwigSimpleResponders.Toot, []},
    {HedwigSimpleResponders.TroutSlap, []},
    {HedwigWunderground.Responder, []},
    {HedwigMopidy.Responders.Mopidy, []},
    {HedwigSimpleResponders.Uptime, []}
  ]

It becomes possible to delegate selection of responders:

config :testbot, Testbot.Robot,
  responders: [
    {Hedwig.Responders.Help, []},
    {Hedwig.Responders.Ping, []},
    {HedwigSimpleResponders, :all, []}, # <--
    {HedwigPlusPlus.Responder, []},
    {HedwigWunderground.Responder, []},
    {HedwigMopidy.Responders.Mopidy, []}
  ]

Any options defined with the collection are in turn passed to the collector function.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 92.105% when pulling 25442dc on labzero:responder-collections into 4031779 on hedwig-im:master.

@doomspork

Copy link
Copy Markdown

@rjanja can't you already define multiple responders inside the same module?

@rjanja

rjanja commented Jun 23, 2017

Copy link
Copy Markdown
Author

@doomspork This may be an edge case, but HedwigSimpleResponders provides a number of responders that would be nice to pull into projects (at least, our project) as a whole. If a module provides multiple responders, users cannot currently include them all in a single line but must include each of them using a separate line of code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants