Написал бота в тг, отслеживает курс доллара биткоина и тд. Начал тестить, попросил друзей тоже потестить, через 3 мин бот перестал отвечать? Что можно сделать?
if message.chat.type == 'private':
if message.text == ' Rate dollar ':
bot.send_sticker(message.chat.id, open('sticker/dollar.webp', 'rb'))
bot.send_message(message.chat.id,' Dollar now: ' + str(cur) + ' ₽ ')
elif message.text == '₿ Rate Bitcoin ₿':
bot.send_sticker(message.chat.id, open('sticker/bitcoin.webp', 'rb'))
bot.send_message(message.chat.id, 'Bitcoin now: ' + str(bit1))
elif message.text == 'Track Bitcoin₿ and Dollar$':
markupda = types.InlineKeyboardMarkup(row_width=True)
kn = types.InlineKeyboardButton('❗️ Track off ❗️', callback_data = 'off')
markupda.add(kn)
bot.send_sticker(message.chat.id, open('sticker/sticker1.webp', 'rb'))
bot.send_message(message.chat.id, 'I started following course $ and ₿.\n You will receive messages every hour \n Dollar now: ' + str(cur) + ' ₽ \n Bitcoin now: ' + str(bit1) + ' ₽ ', reply_markup=markupda )
xt()
while True:
if rate == False:
break
#parsing old
#dollar
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)
#old bit
page_f = requests.get(url2, headers = headers)
pars = BeautifulSoup(page_f.content, 'html.parser')
parsingbit = pars.findAll('span', {'class': 'DFlfde', 'class': 'SwHCTb', 'data-precision': 2})
bitcoin = parsingbit[0].text.replace(',','.')
bit = bitcoin
bitd = ''.join(bit.split())
time.sleep(120)
if rate == False:
break
#parsing new
#dollar
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)
# difference
dif1 = (cur - cur1)
dif2 = (cur1 - cur)
#send message
#dollar
if cur > cur1:
bot.send_sticker(message.chat.id, open('sticker/idollar.webp', 'rb'))
bot.send_message(message.chat.id, ' Course $ increased: ' + str(cur)+ ' ₽\n' + 'Difference: ' + '+' + str(round(dif1, 3)) + ' ₽', reply_markup = markupda)
elif cur < cur1:
bot.send_sticker(message.chat.id, open('sticker/ldollar.webp', 'rb'))
bot.send_message(message.chat.id, ' Course $ lowered: ' + str(cur)+ ' ₽\n' + 'Difference: ' + '-' + str(round(dif2, 3)) + ' ₽')
elif cur == cur1:
bot.send_sticker(message.chat.id, open('sticker/hasdollar.webp', 'rb'))
bot.send_message(message.chat.id, '⚖️ Course $ has not changed: ' + str(cur) + ' ₽')
else:
bot.send_message(message.chat.id, '⭕️ Error ⭕️. Do you want to help me? Write /help_me')
#new bit
page_f1 = requests.get(url2, headers = headers)
pars1 = BeautifulSoup(page_f1.content, 'html.parser')
parsingbit1 = pars1.findAll('span', {'class': 'DFlfde', 'class': 'SwHCTb', 'data-precision': 2})
bitcoin1 = parsingbit1[0].text.replace(',','.')
bit1 = bitcoin1
bit1d = ''.join(bit1.split())
#difference
difference = (float(bitd) - float(bit1d))
difference1 = (float(bit1d) - float(bitd))
if bit > bit1:
bot.send_sticker(message.chat.id, open('sticker/bottom.webp', 'rb'))
bot.send_message(message.chat.id, ' Course ₿ lowered: ' + str(bit1) + ' ₽\n' + 'Difference: ' + '-' + str(round(difference, 3)) + ' ')
elif bit < bit1:
bot.send_sticker(message.chat.id, open('sticker/i.webp', 'rb'))
bot.send_message(message.chat.id, ' Course ₿ increased: ' + str(bit1) + ' ₽\n' + 'Difference: ' + '+' + str(round(difference1, 3)) + ' ')
elif bit == bit1:
bot.send_sticker(message.chat.id, open('sticker/hasdollar.webp', 'rb'))
bot.send_message(message.chat.id, '⚠️ Course ₿ has not changed: ' + str(bit1) + ' ₽')
else:
bot.send_message(message.chat.id, '⭕️ Error ⭕️. Do you want to help me? Write /help_me')