diff --git a/conf/quads.yml b/conf/quads.yml index 7664e3d2d..435b7bbc9 100644 --- a/conf/quads.yml +++ b/conf/quads.yml @@ -40,6 +40,10 @@ ircbot_ipaddr: 192.168.0.100 ircbot_port: 5050 ircbot_channel: #yourchannel +# support for sending webhook notifications on assignment release +webhook_notify: true +webhook_url: https://chat.example.com/v1/spaces/AAABBBCCC + # wordpress wiki wp_wiki: https://wiki.example.com wp_username: wikiadmin diff --git a/quads/tools/notify.py b/quads/tools/notify.py index 79a70ee77..934279332 100755 --- a/quads/tools/notify.py +++ b/quads/tools/notify.py @@ -2,6 +2,7 @@ import asyncio import logging import os +import requests from datetime import datetime, timedelta from enum import Enum @@ -29,10 +30,12 @@ async def create_initial_message(real_owner, cloud, cloud_info, ticket, cc): irc_bot_ip = Config["ircbot_ipaddr"] irc_bot_port = Config["ircbot_port"] irc_bot_channel = Config["ircbot_channel"] + webhook_url = Config["webhook_url"] infra_location = Config["infra_location"] cc_users = Config["report_cc"].split(",") for user in cc: cc_users.append("%s@%s" % (user, Config["domain"])) + if Config["email_notify"]: with open(os.path.join(Config.TEMPLATES_PATH, template_file)) as _file: template = Template(_file.read()) @@ -53,6 +56,7 @@ async def create_initial_message(real_owner, cloud, cloud_info, ticket, cc): content, ) postman.send_email() + if Config["irc_notify"]: try: async with Netcat(irc_bot_ip, irc_bot_port) as nc: @@ -69,6 +73,19 @@ async def create_initial_message(real_owner, cloud, cloud_info, ticket, cc): logger.debug(ex) logger.error("Beep boop netcat can't communicate with your IRC.") + if Config["webhook_notify"]: + try: + message = "QUADS: %s is now active, choo choo! - %s/assignments/#%s - %s %s" % ( + cloud_info, + Config["wp_wiki"], + cloud, + real_owner, + Config["report_cc"], + ) + requests.post(webhook_url, json={'text': message}, headers={'Content-Type': 'application/json'}) + except Exception as ex: + logger.debug(ex) + logger.error("Beep boop we can't communicate with your webhook.") def create_message( cloud_obj,