statBot bug fix on MYR conversion and added testing
StatBot was implemented into #teammalaysia few weeks ago, but there exist a bug on the conversion to MYR (Malaysian Ringgit).
statBot
Commits to github repo
Bug Fixes
- What was the issue(s)?
- Wrongly converted MYR ratio.
- The reason why this happen because the API that I use mistook MYR as MyriadCoin
- Wrongly converted MYR ratio.
- What was the solution?
- Use coinmarketcap's API
- Since coinmarketcap's required long name (e.g.
steem-dollars
), I use hardcoded Short name and Long name pair incrypto.json
from this github repo by @codingdefined.
Fixed bug
New Features
What feature(s) did you add?
- The price now is using CoinMarketCap API, and MYR is correctly converted
- A basic testing is added.
- Added
sbd/s
suggested by @awesomianist
How did you implement it/them?
- Price Codes
crypto.json example
"steem-dollars": "steem-dollars",
"sbd": "steem-dollars",
- Get price with axios library in
api.js
using functions
let getOnlyPrice = async (coin, currency) => {
let res = await axios.get(
`https://api.coinmarketcap.com/v1/ticker/${crypto[coin]}/?convert=${currency}`
).catch((err) => 'Wrong Coin');
let price = res.data[0][`price_${currency.toLowerCase()}`] || '-';
return price;
};
let countRatio = async (coin1, coin2) => {
let coinPrice1, coinPrice2;
return await getOnlyPrice(coin1, 'USD')
.then(price1 => {
coinPrice1 = price1;
return getOnlyPrice(coin2, 'USD').then(price2 => price2);
})
.then(price2 => {
coinPrice2 = price2;
})
.then(() => {
return coinPrice1/coinPrice2;
});
};
- Testing
import { getPrice, getOnlyPrice, countRatio } from '../api';
// api.js
getPrice('steem', 'usd').then(data =>
console.log(`getPrice of Steem: ${data}`)
);
getOnlyPrice('steem', 'usd').then(data =>
console.log(`getOnlyPrice of Steem: ${data}`)
);
countRatio('steem', 'sbd').then(data =>
console.log(`countRatio of Steem/SBD: ${data}`)
);
About the Projects
What is the project about?
Most of our member are on discord all the time, won't it be nice that everything can be done on discord? Therefore, I had this idea of creating a bot that solves my problem, and maybe others too! This bot currently holds utility feature for all steemit user!Technology Stack
Node.jsRoadmap
- Suitable use of SteemSQL to query useful statistics (User status, etc)
- Create an API server instead of inbound SQL queries to seperate API backend with Discord Front end
How to contribute?
This project repo is on GitHub with MIT License. Pull Request Contribution and Issue Filling are welcome.
Posted on Utopian.io - Rewarding Open Source Contributors
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Thank you moderator.
@superoo7, I always try to support who contribute to open source project, upvote you.
Boss, I just realized the logo is S7 😍. Cool la. Reminds me of the legendary Selene S7
Its not S7, it means superoo7, 😂
Hey @superoo7 I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x