skip to Main Content

I wrote a program that automatically sends messages in a telegram group. I use the following code:

import telebot


chat_id = '-123'
API_KEY = '12345'
bot = telebot.TeleBot(API_KEY)


text = 'Hello world!'
bot.send_message(chat_id, text=text)

exit()

And it works perfectly. However, whenever I run the exact same code on my old laptop, it does not work. Does anyone knows what I am doing wrong?

I used the command ‘pip install telebot’ on both laptops.

3

Answers


  1. Chosen as BEST ANSWER

    On my old laptop I had the newest version (4.0.0), that one did not work.

    pip install pyTelegramBotAPI==3.8.2
    

    fixed it for me.


  2. I can see two possible issues:

    1. You didn’t terminate a telebot session on your new notebook while starting it on old one;
    2. Actually, telebot should be installed by ‘pip intall pytelegrambotapi’…
    Login or Signup to reply.
  3. your bot is not being triggered by anything. (command, regex etc)

    Do

    @bot.message_handler(commands=['start'])
    def start_handler(message):
       bot.send_message(message.text.id, "Hello"
    #
    #
    #
    bot.polling()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search