1

I was just doing a simple lines of code and it gives a lot of issues just for using bot.polling().

import telebot

token = '19*******:********-********-lmY'
bot = telebot.TeleBot(token)

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


bot.polling()
vvvvv
  • 25,404
  • 19
  • 49
  • 81
omarhany
  • 13
  • 4

2 Answers2

0

First pip uninstall telebot

Then pip install pyTelegramBotAPI

import telebot

API_KEYS = "API TOKEN"
bot = telebot.TeleBot(API_KEYS)

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

bot.polling()
Piero
  • 404
  • 3
  • 7
  • 22
0

This is likely happening because your environment variable for the API keys is unset:

API_KEYS = os.getenv('API_KEYS')
bot = telebot.TeleBot(API_KEYS)

If the environment variable for 'API_KEYS' is unset, os.getenv will return None. To fix this, make sure the environment variable is set correctly.

To identify this problem more easily in future, you should add key validation to provide a more meaningful error:

try:
    API_KEYS = os.environ['API_KEYS']
except KeyError as error:
    raise ValueError("API keys are missing.") from err

bot = telebot.TeleBot(API_KEYS)
thesketh
  • 319
  • 2
  • 7