R
R
rolton212020-05-20 11:23:01
Python
rolton21, 2020-05-20 11:23:01

When starting the bot tg, I searched the forums for IndentationError: unexpected unindent, did not find it.?

SC:\Users\rolton-tv\Desktop\tg_bot> python qqq.py
File "qqq.py", line 64
bot.polling(none_stop=True)
^
IndentationError: unexpected unindent

Code:

import telebot
import COVID19Py
from telebot import types

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


@bot.message_handler(commands=['start'])
def start(message, tupes=True):
    send_mess = f"привет!"
    # button

    markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
    item1 = types.KeyboardButton("шо по COVID-19")
    markup.add(item1)
    bot.send_message(message.chat.id, send_mess, parse_mode='html', reply_markup=markup)


@bot.message_handler(content_types=['text'])
def mees(message):
    if message.text == 'шо по COVID-19':
        markup = types.InlineKeyboardMarkup(row_width=2)
        item1 = types.KeyboardButton("США", callback_data='US')
        item2 = types.KeyboardButton("Унраина", callback_data='UA')
        item3 = types.KeyboardButton("Россия", callback_data='RU')
        item4 = types.KeyboardButton("Беларусь", callback_data='BU')
        item5 = types.KeyboardButton("Казахстан", callback_data='KZ')
        item6 = types.KeyboardButton("Италия", callback_data='IT')
        item7 = types.KeyboardButton("Франция", callback_data='KZ')
        item8 = types.KeyboardButton("Германия", callback_data='DE')
        item9 = types.KeyboardButton("Япония", callback_data='JP')
        item10 = types.KeyboardButton("Мир", callback_data='bad')

        markup.add(item1, item2, item3, item4, item5, item6, item7, item8, item9, item10)

@bot.callback_query_handler(func=lambda call: True)
def callback_data(call):
     try:
        if call.message:
            if call.data == 'US':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'UA':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'RU':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'BY':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'KZ':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'IT':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'KZ':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'DE':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'JP':
                bot.send_message(call.message.chat.id, 'q')
            elif call.data == 'D':
                bot.send_message(call.message.chat.id, 'q')

bot.polling(none_stop=True)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-05-20
@rolton21

Well, for starters, the try block is not closed (you need to close it):

except Exception as e:
    print(e)

Then there will still be errors related to the keyboard)

A
alternativshik, 2020-05-20
@alternativshik

It would be nice to start learning the basics of the language before trying to write something. Well, the basics of Google, too. Not to find IndentationError - it must be repulsed to the fullest.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question