Answer the question
In order to leave comments, you need to log in
How to handle external events using pytelegrambotapi?
Wrote several bots. In all cases, I managed something like this:
import telebot
bot = telebot.TeleBot(config.token, threaded=True)
@bot.message_handler(commands=['Меню','start','Обновить'])
def menu(message):
markup = types.ReplyKeyboardMarkup()
markup.row('/Обновить')
bot.send_message(message.chat.id, 'Привет ' + message.chat.first_name,reply_markup=markup)
if __name__ == '__main__':
bot.polling(none_stop=True)
Answer the question
In order to leave comments, you need to log in
Look what a fun thing. And you can, and you can’t at the same time...
1. I’ll start small - until you write the first bot - he can’t write to you at all
2. If 1 point is in order, problem number 2 comes - or manually run the script, in which there will be no polling, but only a command to send a message, or throw it into cron, set the frequency of this script to run, and rejoice, or link your sending to some user action.
No, of course you can pervert, and write something like
while true:
if (какое-то условие, допустим, your_date == datetime.today()):
bot.send_message(.....)
time.sleep(60*60) #Время сам уже выбирай
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question