tg_bot/msg/CryptocurrencyMsg.py

22 lines
697 B
Python
Raw Normal View History

2024-12-06 14:20:29 +03:00
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