discord-diabetes / diabot

A diabetes-oriented chatbot for Discord
https://discord.gg/diabetes
Other
21 stars 13 forks source link

Don't convert detected BG values in diabot commands #166

Closed p5nbTgip0r closed 2 years ago

p5nbTgip0r commented 2 years ago

When entering a BG value (or a value that could be seen as a BG value with the <number> <BG unit> format) as an argument to a Diabot command, the bot will respond with a BG conversion and respond with the command's output.

For example:

  1. diabot estimate average 50 mmol
    • Diabot: 50.0 mmol/L is 901 mg/dL
    • Diabot: An A1c of 6.7% (DCCT) or 50.0 mmol/mol (IFCC) is about 146 mg/dL or 8.1 mmol/L
  2. diabot estimate a1c 5 mmol
    • Diabot: 5.0 mmol/L is 90 mg/dL
    • Diabot: An average of 5.0 mmol/L is about 4.8% (DCCT) or 28.6 mmol/mol (IFCC)
  3. diabot estimate a1c 150 mgdl
    • Diabot: 150 mg/dL is 8.3 mmol/L
    • Diabot: An average of 150 mg/dL is about 6.9% (DCCT) or 51.4 mmol/mol (IFCC)
  4. diabot convert 5 mmol
    • Diabot: 5.0 mmol/L is 90 mg/dL
    • Diabot: 5.0 mmol/L is 90 mg/dL

This PR prevents the conversion listener from running on messages that have Diabot's command prefix, making the above situations only respond with the second message of each (which is the executed command's output).