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

Support for multiple webhooks. #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

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