D
D
Dmitry2021-03-19 21:36:18
Python
Dmitry, 2021-03-19 21:36:18

How to fix telegram bot error "AttributeError: 'TeleBot' object has no attribute 'message_handler'"?

Hello! I encountered such a problem that when I run the code, I get an error AttributeError: 'TeleBot' object has no attribute 'message_handler'. Here is the code:

import telebot
import datetime
import requests
import random
from threading import Thread

bot = telebot.TeleBot('токен')

aid =  655437653

#начало диалога
@bot.message_handler(commands=['start'])
def start(message):
    bot.send_message(message.chat.id, 'Привет, ' + str(message.from_user.first_name) + '!' + '\n' + 'Это СМС Бомбер от @Sjjsjwqoa.' + '\n\n' + 'Напиши /help, чтобы посмотреть что я умею.')
    bot.send_message(aid, 'Новый пользователь бота: ' + str(message.from_user.first_name) + " " + str(message.from_user.last_name) + ' (' + str(message.from_user.id) + ')')

@bot.message_handler(commands=['help'])
def help(message):
  bot.send_message(message.chat.id, 'Вот, что я умею:\n/bomb - спам на номер (79xxxxxxxxx RUS)\n\n/id - узнать свой ID\n\n/test - проверка бота на работоспособность\n\n‍♂️/author - инфо об авторе')

@bot.message_handler(commands=['author'])
def authoring(message):
  bot.send_message(message.chat.id, "Автор бота: @D1AM0NDD. По поводу сотрудничества и рекламы писать менеджеру.")

@bot.message_handler(commands=['id'])
def id(message):
  bot.send_message(message.chat.id, 'Ваш ID: ' + str(message.chat.id))

@bot.message_handler(commands=['test'])
def ping(message):
  bot.send_message(message.chat.id, 'Бот Запущен. . . ')


Who knows, please help me understand what's wrong and fix it

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
tka495, 2021-03-20
@D1AM0ND

You need to install pyTelegramBotAPI version 3.6.6. Then it will work.

S
soremix, 2021-03-19
@SoreMix

Probably telebot is installed.

pip uninstall telebot
pip install pytelegrambotapi -U

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question