Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow modules to define collections of responders #67

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rjanja
Copy link

@rjanja rjanja commented Mar 16, 2017

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

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

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

@rjanja
Copy link
Author

rjanja commented Jun 23, 2017

@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