Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from telebot import types
- import logging
- logging.basicConfig(level=logging.DEBUG)
- bot = telebot.TeleBot('6369801748:AAHBTteyu631DWWAJRsAA_fnlRWC5DDRa4g')
- def generate_keyboard():
- keyboard = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True)
- buttons = ['Start', 'Help', 'Open Website', 'Site']
- keyboard.add(*buttons)
- return keyboard
- @bot.message_handler(commands=['start'])
- def start_conversation(message):
- keyboard = generate_keyboard()
- bot.send_message(message.chat.id, f'Привет, {message.from_user.first_name}', reply_markup=keyboard)
- @bot.message_handler(commands=['help'])
- def send_help(message):
- bot.send_message(message.chat.id, "Информация о том, как использовать этого бота.")
- @bot.message_handler(commands=['website', 'site'])
- def open_website(message):
- bot.send_message(message.chat.id, 'https://www.youtube.com/')
- @bot.message_handler(func=lambda message: True)
- def handle_text_messages(message):
- if message.text.lower() == 'start':
- start_conversation(message)
- elif message.text.lower() == 'help':
- send_help(message)
- elif message.text.lower() in ['open website', 'site']:
- open_website(message)
- elif message.text.lower() == 'привет':
- bot.send_message(message.chat.id, f'васап, {message.from_user.first_name}')
- elif message.text.lower() == 'id':
- bot.reply_to(message, f'ID: {message.from_user.id}')
- else:
- bot.send_message(message.chat.id, "Я не понимаю эту команду. Используйте клавиатуру для выбора команды.")
- bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement