P
P
phawer-72020-08-17 12:27:49
Python
phawer-7, 2020-08-17 12:27:49

Telegram bot gives an error, how to fix it?

Code, Main.py:

from bot import *
from telebot import types

@bot.message_handler(commands=['start'])
def send_welcome(message):
    markup_shop = types.ReplyKeyboardMarkup(resize_keyboard=1)
    key1 = types.KeyboardButton("Магазин")
 
    markup_shop.add(key1)
 
    bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}!\nЭто магазин Chaplin Burger, тут можете заказать Фаст-фуд и не только!".format(message.from_user, bot.get_me()),
        parse_mode='html', reply_markup=markup_shop)

@bot.message_handler(content_types=['text'])
def key_shop(message):
    if message.chat.type == 'private':
        if message.text == 'Магазин':
      # инлайн кнопки
            markup_inline_menyu = types.InlineKeyboardMarkup(row_width=3)
      item1 = types.InlineKeyboardButton("Бургер", callback_data='burger')
            item2 = types.InlineKeyboardButton("Лаваш", callback_data='pita')
      item3 = types.InlineKeyboardButton("Напитки", callback_data='beverages')
 
            markup_inline_menyu.add(item1, item2, item3)
 
            bot.send_message(message.chat.id, 'Лови меню))', reply_markup=markup)
        else:
            bot.send_message(message.chat.id, '/start')

@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
    try:
        if call.message:
            if call.data == 'burger':
                bot.send_message(call.message.chat.id, '''Мини Чизбургер - цена 
                    Биг Чизбургер - цена
                    Мини Гамбургер - цена
                    Биг Гамбургер - цена''')
            elif call.data == 'pita':
                bot.send_message(call.message.chat.id, '''Биг лаваш(стандартный) - цена 
        мини лаваш - цена
        мини Лаваш с курицей - цена
   		    биг лаваш с курицей - цена''')
      elif call.data == 'beverages':
    bot.send_messagecall.message.chat.id, '''кока кола(пепси, фанта) 1,5 л - цена
        кока кола(пепси, фанта) 1 л - цена 
                    кока кола(пепси, фанта) 0,5л - цена
        кофе - цена''')
 

            bot.edit_message_text(chat_id=call.message.chat.id, message_id=call.message.message_id, text="Магазин",
                reply_markup=None)
 
            # show alert
            bot.answer_callback_query(callback_query_id=call.id, show_alert=False,
                text="lkjkjkjkjkkjjkjkjkjkjk")
 
    except Exception as e:
        print(repr(e))



@bot.message_handler(commands=['help'])
def send_help(message):
    bot.reply_to(message, "Помощь - +998909299981")

@bot.message_handler(commands=['shop'])
def shop(message):
    bot.send_message(message.chat.id, "Добро пожаловать, {0.first_name}!\nЭто магазин Chaplin Burger, тут можете заказать Фаст-фуд и не только!".format(message.from_user, bot.get_me()),
        parse_mode='html', reply_markup=markup_shop) # команда shop и кнопка при старте должна отправлять одно и тоже
  

@bot.message_handler(commands=['dev'])
def shop(message):
    bot.reply_to(message, "Заказать бота  - @Mrfire7")

@bot.message_handler(commands=['basket'])
def shop(message):
    bot.send_message(message.chat.id, "Корзина. ТЕСТ ТЕСТ ТЕСТ!!!") 

@bot.message_handler(content_types=['location'])
def handle_docs_audio(message):
    bot.reply_to(message, "Тест")

def main():
    bot.polling(none_stop=True)


if __name__ == '__main__':
    main()


Code, bot.py
import telebot 
from config import *

bot = telebot.TeleBot(TOKEN, parse_mode=None)


Code, config.py: Python says tab error, on line 11:
TOKEN = 'мой токен'

item1 = types.InlineKeyboardButton("Бургер", callback_data='burger')


HELP

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
phawer-7, 2020-08-17
@phawer-7

some kind of nonsense turned out, here in some places tabulation works strangely, but in a text editor everything is fine. By the way, the phone number where help is not my
UPD: damn, yes, the error was in the code editor, I opened the file in paycharm and fixed everything.

A
Abdumomin, 2021-12-19
@Abdumomin

I think you also used Visual Studio right?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question