Open Moobiful opened 7 years ago
Currency would actually be pretty easy. http://fixer.io/ provides free exchange rates accurate within the day. Seemingly no limit on API use either.
Other units may take more time to implement since this would require more in-depth parsers. There is Unit.NET which I could use, but would require a lot more work to get this to be as free form as described here..
The non-currency part of this is done. Defaults are not being implemented. I would rather the user be explicit with what they want to convert.
~convert [value][unitA] to [unitB] Would parse a double into an input value register, and parse the units as stated by the user as a string into a current unit register and a target unit register. Then, convert the input value into an output value for the target unit type.
User: "~convert 12kg to ounces" Hourai: "12kg is 423.29oz"
User: "~convert 5 stones to kg" Hourai: "5 stones is 31.75kg"
User: "~convert 60 USD to GBP" Hourai: "60 USD is 46.59GBP"
If the user does not specify a return unit, Hourai would determine whether the input unit was in Metric or Imperial, and convert using the most widely used conversion for the specified unit (gallons <=> liters, fl. oz <=> mL, miles <=> km, feet <=> meters, yards <=> meters, inches <=> cm)
User: "~convert 12kg" Hourai: "12kg is 26.46lbs"
User: "convert 16fl. oz" Hourai: "16 fl. oz is 473.18mL"
User: "~convert 42mi" Hourai: "42mi is 67.59km"
For currency, if the user does not specify a return unit, Hourai could display all conversions from a default list of the most popular currencies and display them on a single line.
User: "~convert 50GBP" Hourai: "50GBP is 64.38USD, 88.32CAD, 59.12EU, 500.98HKD, 7260.52JPY"
Currency is difficult to implement as the conversions constantly change, it might require integration with an already existing database which updates on a frequent basis. I recommend stealing this from some other bot rather than implementing it yourself.