Skip to content

bot dosent run in seperated files #2064

@DiarTor

Description

@DiarTor

Please answer these questions before submitting your issue. Thanks!

  1. What version of pyTelegramBotAPI are you using? 4.14.0

  2. What OS are you using? Windows

  3. What version of python are you using? 3.11.4

hi there, i have this code in my main.py :

from telebot import TeleBot

bot = TeleBot(token="my_bot_token", parse_mode="MARKDOWN")

if name == 'main':
bot.infinity_polling()

and i have this code in my start.py :

from main import bot

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

for some reason when i run main.py and send /start command to the bot it dosen't response but when i put the main.py and start.py in the same file it works fine
can you explain to me why is this hapening and what is the silultion because i want them seperated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions