Answer the question
In order to leave comments, you need to log in
Telegram bot not working in Python?
I wrote a telegram bot in python, but when sending messages it gives an error:
Traceback (most recent call last):
File "C:/Users/User/BotParser/main.py", line 458, in
bot.polling(none_stop=True)
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\telebot\__init__.py", line 633, in polling
self.__threaded_polling(non_stop, interval, timeout, long_polling_timeout, allowed_updates )
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\telebot\__init__.py", line 692, in __threaded_polling
raise e
File "C:\Users\User\AppData \Local\Programs\Python\Python36\lib\site-packages\telebot\__init__.py", line 655, in __threaded_polling
self.worker_pool.raise_exceptions()
File "C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\telebot\util.py", line 130, in raise_exceptions
raise self.exception_info
File " C:\Users\User\AppData\Local\Programs\Python\Python36\lib\site-packages\telebot\util.py", line 82, in run
task(*args, **kwargs)
File "C:/Users /User/BotParser/main.py", line 14, in lala
bot.send.msg(msg.from_user.id, "Expect logs every half an hour!")
AttributeError: 'TeleBot' object has no attribute 'send'
pyTelegramBotAPI library installed
Code:
import telebot
import time
print(dir(telebot))
bot = telebot.TeleBot("%token here%")
num = 1000
@bot.message_handler(content_types = ['text'])
def lala(msg):
if msg.chat.type == 'private':
if msg.text == "Parsing":
bot.send.msg(msg.from_user .id, "Expect logs every half an hour!")
time.sleep(1800)
bot.send.msg(msg.chat.id, "New log!")
Answer the question
In order to leave comments, you need to log in
Pay attention to the error:
AttributeError: 'TeleBot' object has no attribute 'send'
It says that the 'TeleBot' object has no attribute (method) 'send'.
Accordingly, the error is in the lines where you write bot.send.msg
Correct entry:
bot.send_message
Learn to read errors! Happy development!
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question