ebellocchia / telegram_crypto_price_bot

Telegram bot for displaying cryptocurrencies prices and charts
MIT License
53 stars 21 forks source link

Price isn't displayed #6

Closed fouille closed 1 year ago

fouille commented 1 year ago

Hello,

From CoinGecko.

Before i've the price (pair) displayed : Capture d’écran 2022-12-15 aΜ€ 10 40 06

Now the isn't displayed : Capture d’écran 2022-12-15 aΜ€ 10 40 54

BUT price_info_builder.py return good values :

2022-12-15 11:47:57,974 INFO - Executed by user: XXXX (ID: XXXXX)
('**Bitcoin - Price Info**\n'
 '\n'
 '```πŸ’΅  BTC/USD       17664$\n'
 'πŸ“ˆ  High 24h      18323$\n'
 'πŸ“ˆ  Low 24h       17609$\n'
 'πŸ“Š  Volume 24h    27.81B $\n'
 'πŸ’Ž  Market Cap    340.10B $\n'
 '\n'
 'βš– Diff.\n'
 '     24h         πŸ”΄  -0.93%\n'
 '     7d          🟒  +4.82%\n'
 '     14d         🟒  +2.78%\n'
 '     30d         🟒  +6.12%```')

how can i debug this?

thank's

fouille commented 1 year ago

I've solved with workaround

In price_info_builder.py line 92, change :

        # Price info
        msg += self.__PrintAligned(f"πŸ’΅ {coin_pair}", price)
        msg += self.__PrintAligned("πŸ“ˆ High 24h", high_24h)
        msg += self.__PrintAligned("πŸ“ˆ Low 24h", low_24h)
        msg += self.__PrintAligned("πŸ“Š Volume 24h", volume)

        # Market cap
        if self.config.GetValue(BotConfigTypes.PRICE_DISPLAY_MARKET_CAP):
            msg += self.__PrintAligned("πŸ’Ž Market Cap", market_cap)
        # Market cap rank
        if self.config.GetValue(BotConfigTypes.PRICE_DISPLAY_MARKET_CAP_RANK):
            msg += self.__PrintAligned("πŸ† Rank", f"{market_cap_rank:d}")

        # Price differences
        msg += "\nβš– Diff.\n"
        msg += self.__PrintAligned("     24h", change_perc_24h, 1)
        msg += self.__PrintAligned("     7d", change_perc_7d, 1)
        msg += self.__PrintAligned("     14d", change_perc_14d, 1)
        msg += self.__PrintAligned("     30d", change_perc_30d, 1, False)

        # End code
        msg += PriceInfoBuilderConst.MARKDOWN_CODE_DELIM

        return msg

to :

        # Price info
        msg += "\n"
        msg += self.__PrintAligned(f"πŸ’΅ {coin_pair}", price)
        msg += self.__PrintAligned("πŸ“ˆ High 24h", high_24h)
        msg += self.__PrintAligned("πŸ“ˆ Low 24h", low_24h)
        msg += self.__PrintAligned("πŸ“Š Volume 24h", volume)

        # Market cap
        if self.config.GetValue(BotConfigTypes.PRICE_DISPLAY_MARKET_CAP):
            msg += self.__PrintAligned("πŸ’Ž Market Cap", market_cap)
        # Market cap rank
        if self.config.GetValue(BotConfigTypes.PRICE_DISPLAY_MARKET_CAP_RANK):
            msg += self.__PrintAligned("πŸ† Rank", f"{market_cap_rank:d}")

        # Price differences
        msg += "\nβš– Diff.\n"
        msg += self.__PrintAligned("     24h", change_perc_24h, 1)
        msg += self.__PrintAligned("     7d", change_perc_7d, 1)
        msg += self.__PrintAligned("     14d", change_perc_14d, 1)
        msg += self.__PrintAligned("     30d", change_perc_30d, 1, False)

        # End code
        msg += "\n"
        msg += PriceInfoBuilderConst.MARKDOWN_CODE_DELIM

        return msg

insert : msg += "\n" Because de Markdown cote text must be be in the next/previous line.