tg_bot/msg/CryptocurrencyMsg.py
2024-12-06 14:20:29 +03:00

22 lines
697 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from bot.DaMsg import DaMsg
from pycoingecko import CoinGeckoAPI
from bot import config
class CryptocurrencyMsg(DaMsg):
@staticmethod
def get_msg(data=None) -> str:
if data is None:
data = {}
cg = CoinGeckoAPI()
codes = config['CRYPTO_CHARCODES'].split(" ")
res = cg.get_price(ids=codes, vs_currencies=['usd'])
msg = '📈 Курс криптовалют на сегодня:\n\n'
for currency in codes:
msg = msg + "<b>" + currency + "</b>: " + str(res[currency]['usd']) + "$\n\n"
msg = msg + "&#128073; <a href='https://t.me/prosmi_bot'>Предложить новость</a>"
return msg