-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #441 from d-lord/master
Create !crisis, !mentalhealth and !emergency commands
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |