C
C
Chechechevichka2020-06-05 22:34:34
Python
Chechechevichka, 2020-06-05 22:34:34

Strange error?

@bot.message_handler(content_types=['text'])
def start(message):
    if message.text == '/start':
        markup = types.InlineKeyboardMarkup(row_width=1)
        buttons =[
        types.InlineKeyboardButton(
            text='Обратить внимание',
            callback_data='k1'
        ),
        ]
        markup.add(*buttons)
        bot.send_photo(message.from_user.id, img1, caption=text, reply_markup=markup)

@bot.callback_query_handler(func=lambda call: True)
def callback_inline(call):
    try:
        if call.message:
            if call.data == 'k5':
                markup = types.InlineKeyboardMarkup(row_width=1)
                buttonssssfss =[
                types.InlineKeyboardButton(
                 text='А ну давай',
                 url='@kulibenko'
                 ),
                 ]
                markup.add(*buttonssssfss)
                bot.send_photo(call.message.chat.id, img10, caption=text5, reply_markup=markup)
            elif call.data == 'k6':
                markup = types.InlineKeyboardMarkup(row_width=1)
                butto =[
                types.InlineKeyboardButton(
                 text='Ну удачи',
                 url='@kulibenko'
                 ),
                 ]
                markup.add(*butto)
                bot.send_photo(call.message.chat.id, img9, caption=text5, reply_markup=markup)
            elif call.data == 'k1':
                markup = types.InlineKeyboardMarkup(row_width=1)
                buttonss =[
                types.InlineKeyboardButton(
                 text='Сыграть ноктюрн',
                 callback_data='k2'
                 ),
                 ]
                markup.add(*buttonss)
                bot.send_photo(call.message.chat.id, img2, caption=text1, reply_markup=markup)
            elif call.data == 'k2':
                markup = types.InlineKeyboardMarkup(row_width=1)
                buttonsss =[
                types.InlineKeyboardButton(
                 text='Тыкнуть на кнопку',
                 callback_data='k3'
                 ),
                 ]
                markup.add(*buttonsss)
                bot.send_photo(call.message.chat.id, img3, caption=text2, reply_markup=markup)
            elif call.data == 'k3':
                markup = types.InlineKeyboardMarkup(row_width=1)
                buttonssss =[
                types.InlineKeyboardButton(
                 text='ну-ну',
                 callback_data='k4'
                 ),
                 ]
                markup.add(*buttonssss)
                bot.send_photo(call.message.chat.id, img4, caption=text3, reply_markup=markup)
            elif call.data == 'k4':
                markup = types.InlineKeyboardMarkup(row_width=1)
                buttonsssss =[
                types.InlineKeyboardButton(
                 text='Ну... Тебя не существует',
                 callback_data='k5'
                 ),
                 ]
                markup.add(*buttonsssss)
                bot.send_photo(call.message.chat.id, img5, caption=text4, reply_markup=markup)            	
            elif call.data == 'k5':
                markup = types.InlineKeyboardMarkup(row_width=1)
                buttonssssfss =[
                types.InlineKeyboardButton(
                 text='А ну давай',
                 url='@*******'
                 ),
                 ]
                markup.add(*buttonssssfss)
                bot.send_photo(call.message.chat.id, img10, caption=text5, reply_markup=markup)
            else:
            	bot.send_message(message.from_user.id, 'что-то пошло не так')
    except Exception as e:
        print(repr(e))

Here is the error:
ApiException('A request to the Telegram API was unsuccessful. The server returned HTTP 400 Bad Request. Response body:\n[b\'{"ok":false,"error_code":400,"description": "Bad Request: wrong HTTP URL"}\']')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2020-06-05
@Chechechevichka

You must not be opening the image file correctly. I added this code to the top:

with open('1.png','rb') as file:
  img1 = file.read()

UDP:
Links must be in the format 'https://' or 'tg://'

N
NOblo, 2020-06-05
@NOblo

vpn use

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question