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.
This commit is contained in:
Abhijeet Kaur 2017-08-10 05:29:09 +05:30 committed by Tim Abbott
parent a68e582f72
commit c3e2c451a7

View file

@ -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