I want to write a Telegram bot, but I had a problem in the first steps and the bot does not work. The code does not show any error when running without debugging, but it has an error during debugging. Here is my code
import telebot
TOKEN = "#the token"
bot =telebot.TeleBot(TOKEN)
@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.reply_to(message,"#")
@bot.message_handler(commands=['job'])
def send_help(message):
bot.reply_to(message,"#")
@bot.message_handler(func=lambda mass: True)
def echo_all(message):
bot.reply_to(message,"message.text")
bot.infinity_polling()
I tried to write a bot and I expected that at least as far as I have written, I will not encounter any problems because no matter how much I check my code, I don't see any problems in it. But I encountered this error during debugging:
Exception in thread WorkerThread2:
Traceback (most recent call last):
File "c:\Users\ae\AppData\Local\Programs\Python\Python312\Lib\threading.py", line 1073, in _bootstrap_inner
self.run()
File "c:\Users\ae\AppData\Local\Programs\Python\Python312\Lib\site-packages\telebot\util.py", line 81, in run
def run(self):
File "c:\Users\ae\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_trace_dispatch_regular.py", line 203, in trace_dispatch
py_db.enable_tracing(thread_trace_func)
File "c:\Users\ae\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydevd.py", line 1107, in enable_tracing
pydevd_tracing.SetTrace(thread_trace_func)
File "c:\Users\ae\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydevd_tracing.py", line 87,
in SetTrace
if set_trace_to_threads(tracing_func, thread_idents=[thread.get_ident()], create_dummy_thread=False) == 0:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "c:\Users\ae\.vscode\extensions\ms-python.debugpy-2024.2.0-win32-x64\bundled\libs\debugpy\_vendored\pydevd\pydevd_tracing.py", line 354, in set_trace_to_threads
start_new_thread(increase_tracing_count, ())
RuntimeError: can't create new thread at interpreter shutdown '''