@snowmanbb

Process finished with exit code 0 Telebot Python в чем ошибка?

На Pydroid 3 все спокойно работает, запускается. Перенес в PyCharm, появились проблемы. Выдает exit code 0, никаких ошибок, сам пайчарм ни на что не ругается, максимум пара синтаксических помарок (по типу пробелов и тп)

import telebot
from telebot import types

token = 'token'
bot = telebot.TeleBot(token)

name = ''
fnname = ''
platform = ''
balance = 0
deposit = 0

@bot.message_handler(commands=["start"])
def start_message(message):
    if fnname == '' and platform == '':
        bot.send_message(message.chat.id, "Привет! Тебе необходимо зарегистрироваться. /reg")
    elif fnname == '' or platform == '':
        bot.send_message(message.chat.id, "В твоем профиле есть недостающие данные, пройди регистрацию заново. /reg")
    else:
        keyboard = types.InlineKeyboardMarkup()
        key_tournaments = types.InlineKeyboardButton(text='Доступные турниры', callback_data='tournaments')
        key_profile = types.InlineKeyboardButton(text='Профиль', callback_data='profile')
        key_shop = types.InlineKeyboardButton(text='Магазин предметов', callback_data='shop')
        keyboard.add(key_tournaments)
        keyboard.add(key_profile)
        keyboard.add(key_shop)
        bot.send_message(message.chat.id, "Главное меню:", reply_markup=keyboard)


@bot.message_handler(commands=["profile"])
def send_profile(message):
    if fnname != '' and platform != '':
        keyboard = types.InlineKeyboardMarkup()
        key_deposit = types.InlineKeyboardButton(text='Пополнить баланс', callback_data='deposit')
        key_editfnname = types.InlineKeyboardButton(text='Изменить ник', callback_data='editfnname')
        key_editplatform = types.InlineKeyboardButton(text='Изменить платформу', callback_data='editplatform')
        key_back = types.InlineKeyboardButton(text='Назад в меню', callback_data='back')
        keyboard.add(key_deposit)
        keyboard.add(key_editfnname, key_editplatform)
        keyboard.add(key_back)
        bot.send_message(message.chat.id, f'⭐МОЙ ПРОФИЛЬ⭐\n\nЮзернейм: {name}\n\nБаланс: {balance}\n⚡️Никнейм Fortnite: {fnname}\nПлатформа: {platform}',
                         reply_markup=keyboard)
    else:
        bot.send_message(message.chat.id, "В вашем профиле есть недостающие данные, пройдите регистрацию заново. /reg")


@bot.message_handler(commands=["menu"])
def open_menu(message):
    start_message(message)


@bot.message_handler(commands=["reg"])
def register_user(message):
    global name
    name = message.chat.first_name
    msg = bot.send_message(message.chat.id, f'{name}, введи свой никнейм Fortnite:')
    bot.register_next_step_handler(msg, process_fnname_step)


def process_fnname_step(message):
    global fnname
    fnname = message.text
    msg = bot.send_message(message.chat.id, 'Теперь укажи платформу, на которой ты играешь:')
    bot.register_next_step_handler(msg, process_platform_step)


def process_platform_step(message):
    global platform
    platform = message.text
    bot.send_message(message.chat.id,"Спасибо! Теперь ты зарегистрирован. Можешь использовать /start или /menu для открытия главного меню")


def process_new_fnname(message):
    global fnname
    fnname = message.text
    bot.send_message(message.chat.id, f"Никнейм Fortnite успешно изменен на {fnname}")


def process_new_platform(message):
    global platform
    platform = message.text
    bot.send_message(message.chat.id, f"Платформа успешно изменена на {platform}")


@bot.callback_query_handler(func=lambda call: True)
def callback_query(call):
    if call.data == "tournaments":
        pass
    elif call.data == "profile":
        send_profile(call.message)
    elif call.data == "shop":
        keyboard = types.InlineKeyboardMarkup()
        key_unreal = types.InlineKeyboardButton(text='UNREAL PREMIUM', callback_data='unreal')
        key_history = types.InlineKeyboardButton(text='История покупок', callback_data='history')
        key_back = types.InlineKeyboardButton(text='Назад в меню', callback_data='back')
        keyboard.add(key_unreal, key_history)
        keyboard.add(key_back)
        bot.send_message(call.message.chat.id, "Выберите товар:", reply_markup=keyboard)
    elif call.data == "unreal":
        bot.send_message(call.message.chat.id, "Товар находится в разработке")
    elif call.data == "history":
        pass
    elif call.data == "back":
        start_message(call.message)
    elif call.data == "deposit":
        pass
    elif call.data == "editfnname":
        bot.send_message(call.message.chat.id, "Введите новый никнейм Fortnite:")
        bot.register_next_step_handler(call.message, process_new_fnname)
    elif call.data == "editplatform":
        bot.send_message(call.message.chat.id, "Введите вашу актуальную платформу Fortnite:")
        bot.register_next_step_handler(call.message, process_new_platform)

    bot.polling(none_stop=True)
  • Вопрос задан
  • 52 просмотра
Пригласить эксперта
Ответы на вопрос 2
gvelokirov
@gvelokirov
У тебя bot.polling(none_stop=True) в функции, убери пробелы перед bot.polling(none_stop=True)
Ответ написан
@snowmanbb Автор вопроса
Все нашел. Дело было лишь в том, что когда я портировал код на пайчарм (сделал это через тг), каким то образом последняя строчка слетела внутрь тела, стоявшего сверху
bot.polling(none_stop=true)
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы