async def notify( data, notification_type=NOTIFICATION_SUCCESS, username=None, overwrite_url=False, channel=None, ): if notification_type == NOTIFICATION_ERROR: to_send = helpers.error(data) elif notification_type == NOTIFICATION_SUCCESS: to_send = helpers.success(data) elif notification_type == NOTIFICATION_HELP: to_send = helpers.info(data) elif notification_type == NOTIFICATION_RAW: to_send = data else: raise UnknownNotificationType if username: to_send["username"] = username url = None if overwrite_url is not False: url = overwrite_url else: webhook_url_parameter = await ParameterModel.retrieve("webhook_url") if webhook_url_parameter: url = webhook_url_parameter.value if not url: logging.warning( "Unconfigure webhook, please add a slash command and use `/tromino config setup `WEBHOOK URL`" ) return if channel: to_send = {**to_send, "channel": channel} tries = 0 while tries < 5: try: async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout( total=10)) as session: async with session.post(url, json=to_send) as resp: if resp.status != 200: # pragma: no cover logging.warning( f"Notification sent, but response status code is {resp.status}" ) return except aiohttp.ClientError as e: tries += 1 raise e
async def handle_help(self): return helpers.info( "`/tromino monitor mon-{name} [remove] [set-channel [channel]]`")
async def handle_help(self): return helpers.info( "`/tromino monitor [ types_list | create_monitor | mon-{name} ]`")
async def handle_help(self): return helpers.info( "`/tromino monitor create_monitor {name} {type} {interval] [arg1=value1 arg2=value2...}`" )
async def handle_help(self): return helpers.info( "`/tromino monitor types_list` : Give all monitors plugins installed." )
async def handle_help(self): return helpers.info("`/tromino config [setup]`")
async def handle_help(self): return helpers.info( "`/tromino config setup [MATTERMOST INCOMING WEBHOOK URL]`: Setup tromino for the first time" )
async def handle_help(self): return helpers.info("`/tromino [status | config | monitoring]`")