WebHook broker that accepts notifications from multiple platforms and performs simple actions in response
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

slack.py 556B

1234567891011121314151617181920
  1. import json
  2. from .service import Service
  3. class Slack(Service):
  4. def __init__(self):
  5. super().__init__("slack")
  6. def accept_hook(self, identifier, request):
  7. if request.content_type == "application/json":
  8. content = request.json
  9. else:
  10. content = json.loads(request.form["payload"])
  11. text = content["text"]
  12. if "attachments" in content:
  13. text += " " + " ".join(a["fallback"] for a in content["attachments"])
  14. yield {"type": f"slack", "source": identifier, "text": text}