From c3e2c451a778fc3be4f2ef3184ac3b527d28516b Mon Sep 17 00:00:00 2001 From: Abhijeet Kaur Date: Thu, 10 Aug 2017 05:29:09 +0530 Subject: [PATCH] bots: Not printing the users input directly in reply message. In case of an errored input (not consistent with the format of input that the bot seeks), Converter bot was displaying the errored part first, along with the error message. This can lead to many failure, if removing_at_mention function is not working properly then the input '@bot-name 2 m cm' leads to the bot getting stuck in infinite loop as converter bot will want to output '@bot-name not a valid number' and hence calling itself again. --- zulip_bots/zulip_bots/bots/converter/converter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zulip_bots/zulip_bots/bots/converter/converter.py b/zulip_bots/zulip_bots/bots/converter/converter.py index 1e50916..86ee71f 100644 --- a/zulip_bots/zulip_bots/bots/converter/converter.py +++ b/zulip_bots/zulip_bots/bots/converter/converter.py @@ -69,7 +69,7 @@ def get_bot_converter_response(message, bot_handler): exponent = 0 if not is_float(number): - results.append(number + ' is not a valid number. ' + utils.QUICK_HELP) + results.append('`' + number + '` is not a valid number. ' + utils.QUICK_HELP) continue number = float(number) @@ -87,16 +87,16 @@ def get_bot_converter_response(message, bot_handler): ut_to_std = utils.UNITS.get(unit_to, False) if uf_to_std is False: - results.append(unit_from + ' is not a valid unit. ' + utils.QUICK_HELP) + results.append('`' + unit_from + '` is not a valid unit. ' + utils.QUICK_HELP) if ut_to_std is False: - results.append(unit_to + ' is not a valid unit.' + utils.QUICK_HELP) + results.append('`' + unit_to + '` is not a valid unit.' + utils.QUICK_HELP) if uf_to_std is False or ut_to_std is False: continue base_unit = uf_to_std[2] if uf_to_std[2] != ut_to_std[2]: unit_from = unit_from.capitalize() if uf_to_std[2] == 'kelvin' else unit_from - results.append(unit_to.capitalize() + ' and ' + unit_from + + results.append('`' + unit_to.capitalize() + '` and `' + unit_from + '`' + ' are not from the same category. ' + utils.QUICK_HELP) continue