-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot crypto.py
34 lines (24 loc) · 1010 Bytes
/
bot crypto.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from telegram.ext import Updater, CommandHandler
from pycoingecko import CoinGeckoAPI
import pandas as pd
cg = CoinGeckoAPI()
print(cg.get_price(ids='bitcoin,litecoin,ethereum,Tether', vs_currencies='usd'))
def start(bot, update):
bot.send_message(chat_id=update.message.chat_id, text='Hi Welcome to CryptoLand')
cg = CoinGeckoAPI()
def Price(bot, update):
data_market = cg.get_coins_markets(vs_currency="usd")
df_market = pd.DataFrame(data_market, columns=["id", "current_price"])
df_market.set_index("id", inplace=True)
price = df_market.loc["bitcoin"][0]
bot.send_message(chat_id=update.message.chat_id, text=f"{price}")
msg=update.message
print(msg)
with open("token.txt", 'r') as f:
Token = f.read()
updater = Updater(token=Token, base_url="https://tapi.bale.ai/bot")
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start))
dp.add_handler(CommandHandler("price", Price))
updater.start_polling()
updater.idle()