-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
51 lines (38 loc) · 1.63 KB
/
bot.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/python3
import telebot
from telebot.types import Message
from telebot import types
import requests
bot = telebot.TeleBot(TOKEN)
api = "https://min-api.cryptocompare.com/data/pricemulti?fsyms=EDC,DOGE&tsyms=USD,RUR&api_key=c178d4730110d00770f3362944c77b0b6caf2bee7dbb1b3b07bb780210d999bb"
markup = types.ReplyKeyboardMarkup()
itembtn1 = types.KeyboardButton('💰Курсы монеток💰')
markup.row(itembtn1)
@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.reply_to(message, 'Привет!☺️', reply_markup=markup, parse_mode='HTML')
@bot.message_handler(content_types=['text'])
def send_table(message: Message):
if '💰Курсы монеток💰' in message.text:
bot.reply_to(message, 'Ща!️', reply_markup=markup, parse_mode='HTML')
raw_data = requests.get(api).json()
json_edc = raw_data['EDC']
json_doge = raw_data['DOGE']
json_edc_usd = json_edc ['USD']
json_edc_rur = json_edc ['RUR']
json_doge_usd = json_doge ['USD']
json_doge_rur = json_doge ['RUR']
edc_usd = str(json_edc_usd)
edc_rur = str(json_edc_rur)
doge_usd = str(json_doge_usd)
doge_rur = str(json_doge_rur)
bot.send_message(message.chat.id, text="🤓 Курсы такие:\n\n"
+" <b> EDC </b>\n"
+edc_usd+" $\n"
+edc_rur+" ₽\n\n"
+"<b> DOGE </b>\n"
+doge_usd+" $\n"
+doge_rur+" ₽", parse_mode='HTML', reply_markup=markup)
else:
bot.send_message(message.chat.id, 'Чего?😳', parse_mode='HTML', reply_markup=markup)
bot.polling()