Skip to content

Commit 8b7adde

Browse files
committed
Helloworld_defaults: Add sample 'other_commands' to illustrate feature.
Extend tests accordingly.
1 parent e3d2358 commit 8b7adde

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

zulip_bots/zulip_bots/bots/helloworld_defaults/helloworld_defaults.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ def usage(self):
1717

1818
def handle_message(self, message, bot_handler):
1919
default_commands_to_handle = ["", "about", "commands", "help"]
20+
other_commands = {"hello": "Says hello to the user."}
2021
default_response = bot_handler.dispatch_default_commands(message,
2122
default_commands_to_handle,
22-
self.META)
23+
self.META,
24+
other_commands)
2325
if default_response is not None:
2426
bot_handler.send_reply(message, default_response)
2527
return
2628

29+
if message['content'].startswith('hello'):
30+
bot_handler.send_reply(message, "Hello!")
31+
return
32+
2733
content = 'beep boop'
2834
bot_handler.send_reply(message, content)
2935

zulip_bots/zulip_bots/bots/helloworld_defaults/test_helloworld_defaults.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def test_bot(self):
1717
beep_messages = ["foo", "Hi, my name is abc"]
1818
self.check_expected_responses(list(zip(beep_messages, len(beep_messages)*[txt])))
1919

20+
self.check_expected_responses([("hello", "Hello!")])
21+
2022
# Don't check for these, as they are handled by default in the library
2123
# ""
2224
# "about"

0 commit comments

Comments
 (0)