link_shortener: Print help
when no links found.
This commit is contained in:
parent
3db070b99e
commit
e81942421e
|
@ -40,16 +40,18 @@ class LinkShortenerHandler(object):
|
|||
')'
|
||||
)
|
||||
|
||||
HELP_STR = (
|
||||
'Mention the link shortener bot in a conversation and '
|
||||
'then enter any URLs you want to shorten in the body of '
|
||||
'the message.'
|
||||
)
|
||||
|
||||
content = message['content']
|
||||
|
||||
if content.strip() == 'help':
|
||||
bot_handler.send_reply(
|
||||
message,
|
||||
(
|
||||
'Mention the link shortener bot in a conversation and '
|
||||
'then enter any URLs you want to shorten in the body of '
|
||||
'the message.'
|
||||
)
|
||||
HELP_STR
|
||||
)
|
||||
return
|
||||
|
||||
|
@ -67,7 +69,7 @@ class LinkShortenerHandler(object):
|
|||
if final_response == '':
|
||||
bot_handler.send_reply(
|
||||
message,
|
||||
'No links found. Send "help" to see usage instructions.'
|
||||
'No links found. ' + HELP_STR
|
||||
)
|
||||
return
|
||||
|
||||
|
|
|
@ -13,7 +13,11 @@ class TestLinkShortenerBot(BotTestCase):
|
|||
|
||||
def test_bot_responds_to_empty_message(self) -> None:
|
||||
with patch('requests.get'):
|
||||
self._test('', 'No links found. Send "help" to see usage instructions.')
|
||||
self._test('',
|
||||
('No links found. '
|
||||
'Mention the link shortener bot in a conversation and '
|
||||
'then enter any URLs you want to shorten in the body of '
|
||||
'the message.'))
|
||||
|
||||
def test_normal(self) -> None:
|
||||
with self.mock_http_conversation('test_normal'):
|
||||
|
@ -26,7 +30,10 @@ class TestLinkShortenerBot(BotTestCase):
|
|||
# requests.
|
||||
with patch('requests.get'):
|
||||
self._test('Shorten nothing please.',
|
||||
'No links found. Send "help" to see usage instructions.')
|
||||
('No links found. '
|
||||
'Mention the link shortener bot in a conversation and '
|
||||
'then enter any URLs you want to shorten in the body of '
|
||||
'the message.'))
|
||||
|
||||
def test_help(self) -> None:
|
||||
# No `mock_http_conversation` is necessary because the bot will
|
||||
|
|
Loading…
Reference in a new issue