Reply in Telegram with the current price and market figures for any ticker symbol someone asks about.
Uses
CoinMarketCap
Telegram
Look up a crypto price from Telegram
message.When a new message is received. Save it as message.priceKeyword to blank.Set priceKeyword to blank.coinsSearched to 300.Set coinsSearched to 300.chatId to message.chat_id.Set chatId to message.chat_id.messageText to blank.Set messageText to blank.noTextErrorIf a step below fails, save the error as noTextErrorTry
message.text and save it as messageText.Trim message.text and save it as messageText.On error
This message carried no text, so there was nothing to look up..Show in the output: This message carried no text, so there was nothing to look up..messageText is emptyIf messageText is emptyYes
No
No steps
messageText by a space and save it as words.Split messageText by a space and save it as words.words[0] lowercase and save it as commandWord.Make words[0] lowercase and save it as commandWord.commandWord is not priceKeyword in lowercaseIf commandWord is not priceKeyword in lowercaseYes
No
No steps
requestedSymbol to blank.Set requestedSymbol to blank.symbolErrorIf a step below fails, save the error as symbolErrorTry
$ with in words[1] in uppercase and save it as requestedSymbol.Replace $ with in words[1] in uppercase and save it as requestedSymbol.On error
No ticker symbol followed the keyword..Show in the output: No ticker symbol followed the keyword..requestedSymbol is empty or the length of requestedSymbol is greater than 12If requestedSymbol is empty or the length of requestedSymbol is greater than 12Yes
chatId.Send a message to chat chatId.Send a ticker symbol after '@priceKeyword', for example: priceKeyword BTCNo
No steps
listings.Get top CoinMarketCap cryptocurrencies. Save it as listings.rows to listings.listings.data.Set rows to listings.listings.data.matched to false.Set matched to false.coinName to nothing.Set coinName to nothing.coinRank to nothing.Set coinRank to nothing.usdQuote to nothing.Set usdQuote to nothing.row in rows:For each row in rows:row.symbol is requestedSymbolIf row.symbol is requestedSymbolYes
matched to true.Change matched to true.coinName to row.name.Change coinName to row.name.coinRank to row.cmc_rank.Change coinRank to row.cmc_rank.usdQuote to row.quote.USD.Change usdQuote to row.quote.USD.No
No steps
matched is noIf matched is noYes
chatId.Send a message to chat chatId.I could not find requestedSymbol in the top coinsSearched as text cryptocurrencies by market cap on CoinMarketCap. Check the ticker symbol and try again.requestedSymbol.Finish the run: No coin on CoinMarketCap matched requestedSymbol.No
No steps
replyLines to an empty list.Set replyLines to an empty list.heading to requestedSymbol.Set heading to requestedSymbol.coinName isn't emptyIf coinName isn't emptyYes
heading to coinName (requestedSymbol).Change heading to coinName (requestedSymbol).No
No steps
heading to the end of replyLines and save it as replyLines.Add heading to the end of replyLines and save it as replyLines.priceLine to Price: not reported by CoinMarketCap.Set priceLine to Price: not reported by CoinMarketCap.priceRaw to usdQuote.price.Set priceRaw to usdQuote.price.priceRaw isn't emptyIf priceRaw isn't emptyYes
priceErrorIf a step below fails, save the error as priceErrorTry
priceNumber to priceRaw multiplied by 1.Set priceNumber to priceRaw multiplied by 1.priceNumber is less than 1If priceNumber is less than 1Yes
priceLine to Price: priceNumber formatted as US dollars with 8 decimal places.Change priceLine to Price: priceNumber formatted as US dollars with 8 decimal places.No
priceLine to Price: priceNumber formatted as US dollars with 2 decimal places.Change priceLine to Price: priceNumber formatted as US dollars with 2 decimal places.On error
The price came back in a form that is not a number, so it was left out..Show in the output: The price came back in a form that is not a number, so it was left out..No
No steps
priceLine to the end of replyLines and save it as replyLines.Add priceLine to the end of replyLines and save it as replyLines.hourChangeRaw to usdQuote.percent_change_1h.Set hourChangeRaw to usdQuote.percent_change_1h.hourChangeRaw isn't emptyIf hourChangeRaw isn't emptyYes
hourChangeRawErrorIf a step below fails, save the error as hourChangeRawErrorTry
hourChangeRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.Add 1h change: hourChangeRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.On error
A percentage came back in a form that is not a number, so it was left out..Show in the output: A percentage came back in a form that is not a number, so it was left out..No
No steps
dayChangeRaw to usdQuote.percent_change_24h.Set dayChangeRaw to usdQuote.percent_change_24h.dayChangeRaw isn't emptyIf dayChangeRaw isn't emptyYes
dayChangeRawErrorIf a step below fails, save the error as dayChangeRawErrorTry
dayChangeRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.Add 24h change: dayChangeRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.On error
A percentage came back in a form that is not a number, so it was left out..Show in the output: A percentage came back in a form that is not a number, so it was left out..No
No steps
marketCapRaw to usdQuote.market_cap.Set marketCapRaw to usdQuote.market_cap.marketCapRaw isn't emptyIf marketCapRaw isn't emptyYes
marketCapRawErrorIf a step below fails, save the error as marketCapRawErrorTry
marketCapRaw multiplied by 1 formatted as US dollars with 0 decimal places to the end of replyLines and save it as replyLines.Add Market cap: marketCapRaw multiplied by 1 formatted as US dollars with 0 decimal places to the end of replyLines and save it as replyLines.On error
A market figure came back in a form that is not a number, so it was left out..Show in the output: A market figure came back in a form that is not a number, so it was left out..No
No steps
rankRaw to coinRank.Set rankRaw to coinRank.rankRaw isn't emptyIf rankRaw isn't emptyYes
rankRawErrorIf a step below fails, save the error as rankRawErrorTry
rankRaw multiplied by 1 formatted as a plain number with 0 decimal places to the end of replyLines and save it as replyLines.Add Market cap rank: #rankRaw multiplied by 1 formatted as a plain number with 0 decimal places to the end of replyLines and save it as replyLines.On error
A market figure came back in a form that is not a number, so it was left out..Show in the output: A market figure came back in a form that is not a number, so it was left out..No
No steps
fearGreedErrorIf a step below fails, save the error as fearGreedErrorTry
fearGreed.Get CoinMarketCap Fear and Greed Index. Save it as fearGreed.fearGreedData to fearGreed.fear_and_greed.data.Set fearGreedData to fearGreed.fear_and_greed.data.fearGreedValue to fearGreedData.value.Set fearGreedValue to fearGreedData.value.fearGreedLabel to fearGreedData.value_classification.Set fearGreedLabel to fearGreedData.value_classification.fearGreedValue isn't emptyIf fearGreedValue isn't emptyYes
fearGreedLine to CoinMarketCap Fear and Greed Index: fearGreedValue multiplied by 1 formatted as a plain number with 0 decimal places.Set fearGreedLine to CoinMarketCap Fear and Greed Index: fearGreedValue multiplied by 1 formatted as a plain number with 0 decimal places.fearGreedLabel isn't emptyIf fearGreedLabel isn't emptyYes
fearGreedLine to fearGreedLine (fearGreedLabel).Change fearGreedLine to fearGreedLine (fearGreedLabel).No
No steps
fearGreedLine to the end of replyLines and save it as replyLines.Add fearGreedLine to the end of replyLines and save it as replyLines.No
No steps
On error
The Fear and Greed Index could not be read, so it was left out of the reply..Show in the output: The Fear and Greed Index could not be read, so it was left out of the reply..globalErrorIf a step below fails, save the error as globalErrorTry
globalMetrics.Get global market data. Save it as globalMetrics.globalData to globalMetrics.metrics.data.Set globalData to globalMetrics.metrics.data.dominanceRaw to globalData.btc_dominance.Set dominanceRaw to globalData.btc_dominance.dominanceRaw isn't emptyIf dominanceRaw isn't emptyYes
dominanceRawErrorIf a step below fails, save the error as dominanceRawErrorTry
dominanceRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.Add Bitcoin share of total market cap: dominanceRaw multiplied by 1 formatted as a plain number with 2 decimal places% to the end of replyLines and save it as replyLines.On error
A market figure came back in a form that is not a number, so it was left out..Show in the output: A market figure came back in a form that is not a number, so it was left out..No
No steps
totalCapRaw to globalData.quote.USD.total_market_cap.Set totalCapRaw to globalData.quote.USD.total_market_cap.totalCapRaw isn't emptyIf totalCapRaw isn't emptyYes
totalCapRawErrorIf a step below fails, save the error as totalCapRawErrorTry
totalCapRaw multiplied by 1 formatted as US dollars with 0 decimal places to the end of replyLines and save it as replyLines.Add Total crypto market cap: totalCapRaw multiplied by 1 formatted as US dollars with 0 decimal places to the end of replyLines and save it as replyLines.On error
A market figure came back in a form that is not a number, so it was left out..Show in the output: A market figure came back in a form that is not a number, so it was left out..No
No steps
On error
Global market figures could not be read, so they were left out of the reply..Show in the output: Global market figures could not be read, so they were left out of the reply..Observed market data from CoinMarketCap. Not financial advice. to the end of replyLines and save it as replyLines.Add Observed market data from CoinMarketCap. Not financial advice. to the end of replyLines and save it as replyLines.chatId.Send a message to chat chatId.replyLines joined by a new line