Бот в тг. Отслеживает курс доллара и отправляет сообщения об долларе (упал, вырос). Не понимаю как сделать задержку программы от пользователя. Ввод пользователя чере inline keyboard:
код:
elif message.text == ' Track dollar ':
#keyboard inline
markup = types.InlineKeyboardMarkup(row_width = 2)
kb1 = types.InlineKeyboardButton('10 min', callback_data = '10')
kb2 = types.InlineKeyboardButton('1 horse', callback_data = '1h')
kb3 = types.InlineKeyboardButton('5 horse', callback_data = '10h')
markup.add(kb1, kb2, kb3)
#send message
bot.send_message(message.chat.id, ' Now I am tracking the dollar. ⚡️ \n How long does it take for me to receive notifications❓ \n \n ', reply_markup = markup)
xt()
while True:
if rate == False:
break
full_page1 = requests.get(url, headers = headers)
soup1 = BeautifulSoup(full_page1.content, 'html.parser')
convert1 = soup1.findAll('span', {'class': 'DFlfde', 'class': 'SwHCTb', 'data-precision': 2})
currency1 = convert1[0].text.replace(',','.')
cur1 = float(currency1)
inline()
if rate == False:
break
#parsing()
full_page = requests.get(url, headers = headers)
soup = BeautifulSoup(full_page.content, 'html.parser')
convert = soup.findAll('span', {'class': 'DFlfde', 'class': 'SwHCTb', 'data-precision': 2})
currency = convert[0].text.replace(',','.')
cur = float(currency)
if cur > cur1:
bot.send_message(message.chat.id, ' Course increased: ' + str(cur) + ' ')
elif cur < cur1:
bot.send_message(message.chat.id, ' Course lowered: ' + str(cur) + ' ')
elif cur == cur1:
bot.send_message(message.chat.id, '⚖️ Course has not changed ' + str(cur) + ' 〽️')
@bot.callback_query_handler(func = lambda call: True)
def inline (call):
if call.message:
if call.data == '10':
time.sleep(10)
elif call.data == '1h':
time.sleep(30)
elif call.data == '10h':
time.sleep(60)