diff --git a/zulip_bots/zulip_bots/bots/xkcd/test_xkcd.py b/zulip_bots/zulip_bots/bots/xkcd/test_xkcd.py index f454c05..c4b80a2 100755 --- a/zulip_bots/zulip_bots/bots/xkcd/test_xkcd.py +++ b/zulip_bots/zulip_bots/bots/xkcd/test_xkcd.py @@ -44,10 +44,11 @@ class TestXkcdBot(BotTestCase): help_txt = "xkcd bot supports these commands:" err_txt = "xkcd bot only supports these commands, not `{}`:" commands = ''' -* `@xkcd help` to show this help message. -* `@xkcd latest` to fetch the latest comic strip from xkcd. -* `@xkcd random` to fetch a random comic strip from xkcd. -* `@xkcd ` to fetch a comic strip based on `` e.g `@xkcd 1234`.''' +* `{0} help` to show this help message. +* `{0} latest` to fetch the latest comic strip from xkcd. +* `{0} random` to fetch a random comic strip from xkcd. +* `{0} ` to fetch a comic strip based on `` e.g `{0} 1234`.'''.format( + "@**test-bot**") self.verify_reply('', err_txt.format('') + commands) self.verify_reply('help', help_txt + commands) # Example invalid command diff --git a/zulip_bots/zulip_bots/bots/xkcd/xkcd.py b/zulip_bots/zulip_bots/bots/xkcd/xkcd.py index bf44d20..d473922 100644 --- a/zulip_bots/zulip_bots/bots/xkcd/xkcd.py +++ b/zulip_bots/zulip_bots/bots/xkcd/xkcd.py @@ -35,7 +35,8 @@ class XkcdHandler(object): ''' def handle_message(self, message: Dict[str, str], bot_handler: Any) -> None: - xkcd_bot_response = get_xkcd_bot_response(message) + quoted_name = bot_handler.identity().mention + xkcd_bot_response = get_xkcd_bot_response(message, quoted_name) bot_handler.send_reply(message, xkcd_bot_response) class XkcdBotCommand(object): @@ -49,16 +50,16 @@ class XkcdNotFoundError(Exception): class XkcdServerError(Exception): pass -def get_xkcd_bot_response(message: Dict[str, str]) -> str: +def get_xkcd_bot_response(message: Dict[str, str], quoted_name: str) -> str: original_content = message['content'].strip() command = original_content.strip() commands_help = ("%s" - "\n* `@xkcd help` to show this help message." - "\n* `@xkcd latest` to fetch the latest comic strip from xkcd." - "\n* `@xkcd random` to fetch a random comic strip from xkcd." - "\n* `@xkcd ` to fetch a comic strip based on `` " - "e.g `@xkcd 1234`.") + "\n* `{0} help` to show this help message." + "\n* `{0} latest` to fetch the latest comic strip from xkcd." + "\n* `{0} random` to fetch a random comic strip from xkcd." + "\n* `{0} ` to fetch a comic strip based on `` " + "e.g `{0} 1234`.".format(quoted_name)) try: if command == 'help':