Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit converter #17

Open
Moobiful opened this issue May 4, 2017 · 2 comments
Open

Add unit converter #17

Moobiful opened this issue May 4, 2017 · 2 comments

Comments

@Moobiful
Copy link

Moobiful commented May 4, 2017

~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.

@james7132
Copy link
Owner

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

@james7132
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants