Skip to content

Commit

Permalink
Merge pull request #441 from d-lord/master
Browse files Browse the repository at this point in the history
Create !crisis, !mentalhealth and !emergency commands
  • Loading branch information
nicklambourne authored May 26, 2019
2 parents e3cdbd6 + f5ebca8 commit dad22da
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/test_crisis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from test.conftest import MockUQCSBot, TEST_CHANNEL_ID


def test_crisis_keyword(uqcsbot: MockUQCSBot):
'''
Ensure !crisis returns the intended resource
'''
uqcsbot.post_message(TEST_CHANNEL_ID, '!crisis')
messages = uqcsbot.test_messages.get(TEST_CHANNEL_ID, [])
assert len(messages) == 2
assert "campus security" in messages[-1]['text'].lower()


def test_mentalhealth_keyword(uqcsbot: MockUQCSBot):
'''
Ensure !mentalhealth also returns the intended resource
'''
uqcsbot.post_message(TEST_CHANNEL_ID, '!mentalhealth')
messages = uqcsbot.test_messages.get(TEST_CHANNEL_ID, [])
assert len(messages) == 2
assert "campus security" in messages[-1]['text'].lower()


def test_emergency_keyword(uqcsbot: MockUQCSBot):
'''
Ensure !emergency also does the needful
'''
uqcsbot.post_message(TEST_CHANNEL_ID, '!emergency')
messages = uqcsbot.test_messages.get(TEST_CHANNEL_ID, [])
assert len(messages) == 2
assert "campus security" in messages[-1]['text'].lower()
20 changes: 20 additions & 0 deletions uqcsbot/scripts/crisis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from uqcsbot import bot, Command

RESPONSE = """*Mental health/crisis resources*
24/7 UQ Counselling and Crisis Line: 1300 851 998
Campus Security (emergency): 07 3365 3333
Campus Security (non-emergency): 07 3365 1234
Counselling Services: https://www.uq.edu.au/student-services/counselling-services
UQ Psychology Clinic: https://clinic.psychology.uq.edu.au/therapies-and-services
UQ resources: https://about.uq.edu.au/campaigns-and-initiatives/mental-health"""


@bot.on_command("crisis")
@bot.on_command("mentalhealth")
@bot.on_command("emergency")
def handle_crisis(command: Command):
'''
`!crisis`, `!mentalhealth` or `emergency` - Get a list of emergency resources.
'''

bot.post_message(command.channel_id, RESPONSE)

0 comments on commit dad22da

Please sign in to comment.