Answer the question
In order to leave comments, you need to log in
Trouble writing a Telegram bot in Python?
I welcome everyone! I decided to write a bot for Telegram, to try myself in this area. Here is the code:
import telebot
bot = telebot.TeleBot('токен')
@bot.message_handler(content_types=['text'])
def get_text_messages(message):
if message.text == "Привет":
bot.send_message(message.from_user.id, "Привет, я ВЕЛИКИЙ БОТ ВИТАЛИЙ, но ты можешь звать меня Витя, чем я могу тебе помочь?")
elif message.text == "/help":
bot.send_message(message.from_user.id, "Напиши привет")
else:
bot.send_message(message.from_user.id, "Я тебя не понимаю. Напиши /help.")
bot.polling(none_stop=True, interval=0)
Answer the question
In order to leave comments, you need to log in
I do this (in order not to bother with connecting through a proxy): I upload my script to www.pythonanywhere.com and run it there, after installing the necessary modules. For the test, the free tariff is enough for the eyes. And if you wish, you can then run it using cron
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question