C
C
Chris2021-05-23 10:38:49
Python
Chris, 2021-05-23 10:38:49

How to set url link in buttons in telegram bot?

I am attaching the code below. I would like to put in "hi" a large number of links to lectures from YouTube, which would be clickable. How to beat? I will be very grateful. Also, if possible, how to make a submenu in "hi3" so that manuals from my computer are sent from the computer to the users of the bot, but first they will have to choose which one they want in this submenu. Thanks to!

import telebot
from telebot import types


TOKEN = '-'
bot = telebot.TeleBot(TOKEN)






@bot.message_handler(commands=['start'])
def inline(message):
    markup = types.InlineKeyboardMarkup(row_width=2)
    item = types.InlineKeyboardButton('Лекции по ',callback_data='hi')
    item2 = types.InlineKeyboardButton('Лекции по ', callback_data='hi1')
    item4 = types.InlineKeyboardButton('Расписание', callback_data='hi2')
    item3 = types.InlineKeyboardButton('Методички', callback_data='hi3')
    item5 = types.InlineKeyboardButton('Инстаграм ', callback_data='hi4')
    markup.add(item, item2, item3, item4, item5)
    bot.send_message(message.chat.id, 'Привет! Выбери нужный тебе материал', reply_markup=markup)

@bot.callback_query_handler(func=lambda call:True)
def data(call):
    if call.message:
        if call.data == 'hi':
            bot.send_message(call.message.chat.id, 'Выбери лекцию по ')
        elif call.data == 'hi1':
            bot.send_message(call.message.chat.id, 'Пока')
        elif call.data == 'hi2':
            bot.send_document(call.message.chat.id, open(r'C:\\Users\\raspisanie.jpg', 'rb'))
        elif call.data == 'hi4':
            bot.send_message(call.message.chat.id, 'https://www.instagram.com/')
        elif call.data == 'hi3':
            bot.send_message(call.message.chat.id, 'условно будет стоять ссылка на методички')



bot.polling()

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question