Answer the question
In order to leave comments, you need to log in
Schedule not working, why?
Introduced schedule so that a message is sent every 10 minutes, but for some reason it only sends once and crashes. What is the reason?
Here is the code:
import schedule
import time
import random
import telebot
bot = telebot.TeleBot('Token')
eng_word = ['weather — погода','fine — прекрасный','terrible — ужасный','cold — холодный','hot — жаркий']
@bot.message_handler(commands=['start'])
def welcome(message):
bot.send_message(message.chat.id, "Привет, {0.first_name}!\nЯ -<b>{1.first_name}</b>, бот который поможет выучить английские слова)".format(message.from_user, bot.get_me()),
parse_mode='html')
@bot.message_handler(commands= ['learn'])
def learn(message):
bot.send_message(message.chat.id, random.choice(eng_word))
schedule.every(10).minutes.do(learn)
while True:
schedule.run_pending()
time.sleep(1)
bot.polling(none_stop=True)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question