nameerror : name 'bot' is not defined

26 views Asked by At

i am trying to create a telegram bot and its having issues

import os
import telebot

my_secret = os.environ['Example']

@bot.message_handler(command=['Greet'])
def greet(message):
  bot.reply_to(message, "Hey! Hows it going?")

bot.polling()
1

There are 1 answers

0
AdityaDN On

As stated in the error you haven't defined bot before using that variable. If you check the offical docs of pyTelegramBotAPI, even the example shows how to start by defining bot (https://pypi.org/project/pyTelegramBotAPI/):

import telebot

bot = telebot.TeleBot("TOKEN", parse_mode=None)

@bot.message_handler(commands=['start', 'help'])
def send_welcome(message):
    bot.reply_to(message, "Howdy, how are you doing?")```