Open ckennedy-proto opened 5 years ago
Related to #58
To add to this a bit - it appears some of the default handlers are included in the packaged version such as:
:wave: Don't forget to fill out an incident report here: http://localhost:8000/incident/1/
Is there a way to modify these?
To your original question - that's odd 🤔 my first thought is that Python isn't importing that file, even though you've imported it in manage.py
. Could you try adding an raise RuntimeError("test")
to the main body of the file, and see if it loudly fails?
If not, then you might need to add the import somewhere else - e.g. app.py
As to overriding the default handlers, it's not possible just yet. We've done something like this for @incident_command
, so e.g. you can override the @incident severity
command like this:
@incident_command(['severity', 'sev'], helptext='Set the incident severity')
def set_severity(incident: Incident, user_id: str, message: str):
logger.info("Handling severity command")
for sev_id, sev_name in Incident.SEVERITIES:
# look for sev name (e.g. critical) or sev id (1)
if (sev_name in message) or (sev_id in message):
incident.severity = sev_id
incident.save()
comms_channel.post_in_channel(f"Setting severity to {sev_name}")
return True, None
return False, None
I'd like to do something similar for handlers too
I was able to work through this, thanks for the help.
In regards to the overriding - would it be possible to prioritize custom vs. built in, in a similar case as you've described for incident_command? That way any custom take priority, and if none exist for a specific command, then the default is chosen.
Hello,
I am trying to leverage the packaged version, and adding additional functionality per this documentation: https://github.com/monzo/response/blob/master/docs/development.md
In manage.py I've added:
import ui.keyword_handlers
I've created a new file called keyword_handlers.py:
This isn't working though. How can I add this additional functionality to the packaged version?
Thank you.