Skip to content

Support for multiple webhooks.#22

Open
versx wants to merge 4 commits intomzsmakr:masterfrom
versx:webhooks
Open

Support for multiple webhooks.#22
versx wants to merge 4 commits intomzsmakr:masterfrom
versx:webhooks

Conversation

@versx
Copy link

@versx versx commented Aug 31, 2018

Adds support for multiple webhook endpoints.

Example use is I use a Discord bot and a PokeAlarm instance.

@123FLO321
Copy link
Collaborator

maybe rename WEBHOOK to WEBHOOKS

maybe also legacy support for WEBHOOK

try: 
   WEBHOOKS = [WEBHOOK]
except NameError:
   pass

Copy link

@M4d40 M4d40 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better add the string check and transform it if needed to a list.

That way both WEBHOOKS are valid.
A Single one as String and also a List.

(Also that way it is backwards compatible)

raidnearby.py Outdated
headers={'Content-Type': 'application/json'}
)
LOG.info('Webhook is send.')
for wh in self.config.WEBHOOK:
Copy link

@M4d40 M4d40 Aug 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conf_webhook = self.config.WEBHOOK
if isinstance(conf_webhook , str):
    conf_webhook = [conf_webhook ]

for wh in conf_webhook:

@versx
Copy link
Author

versx commented Sep 1, 2018

How about something like this in order to add legacy support? @123FLO321

try:
    webhooks = [self.config.WEBHOOK]
except AttributeError:
    webhooks = self.config.WEBHOOKS

for wh in webhooks:

or

if hasattr(self.config.WEBHOOK, 'property'):

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.

3 participants