|
import telebot |
|
import os |
|
|
|
|
|
TELEGRAM_TOKEN = os.getenv('TELEGRAM_TOKEN') |
|
|
|
|
|
if TELEGRAM_TOKEN is None: |
|
print("Ошибка: переменная окружения TELEGRAM_TOKEN не установлена!") |
|
exit(1) |
|
|
|
|
|
bot = telebot.TeleBot(TELEGRAM_TOKEN) |
|
|
|
|
|
@bot.message_handler(commands=['start']) |
|
def send_welcome(message): |
|
bot.reply_to(message, "Привет! Я твой Telegram бот!") |
|
|
|
|
|
@bot.message_handler(func=lambda message: True) |
|
def echo_all(message): |
|
bot.reply_to(message, f"Ты сказал: {message.text}") |
|
|
|
|
|
if __name__ == '__main__': |
|
print("Бот запущен...") |
|
bot.polling(none_stop=True) |
|
|