Advertisement
openmsk

bot v1

Sep 21st, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.87 KB | None | 0 0
  1. #source tenv/bin/activate
  2.  
  3. import telebot
  4. from telebot import types
  5.  
  6. TOKEN = 'sdjhgsdf'
  7. bot = telebot.TeleBot(TOKEN)
  8. @bot.message_handler(commands=['start'])
  9. def start(m):
  10.     msg = bot.send_message(m.chat.id, 'Привет всем в этом чате')
  11.     keyboard = types.ReplyKeyboardMarkup(row_width=2)
  12.     keyboard.add(*[types.KeyboardButton(name) for name in ['Choice one', 'Choice two']])
  13.     msg = bot.send_message(m.chat.id, 'Выбирай', reply_markup=keyboard)
  14.     bot.register_next_step_handler(msg, name)
  15.  
  16. def name(m):
  17.     if m.text == 'Choice one':
  18.         bot.send_message(m.chat.id, 'Описание первого выбора', parse_mode='Markdown')
  19.     if m.text == 'Choice two':
  20.         bot.send_message(m.chat.id, 'Описание второго выбора', parse_mode='Markdown')
  21.  
  22. @bot.message_handler(commands=['geophone'])
  23. def geophone(message):
  24.     # Эти параметры для клавиатуры необязательны, просто для удобства
  25.     keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
  26.     button_phone = types.KeyboardButton(text="Отправить номер телефона", request_contact=True)
  27.     # button_geo = types.KeyboardButton(text="Отправить местоположение", request_location=True)
  28.     keyboard.add(button_phone)
  29.     bot.send_message(message.chat.id, "Отправь мне свой номер телефона", reply_markup=keyboard)
  30.  
  31. @bot.message_handler(content_types=["text"])
  32. def default_test(message):
  33.     keyboard = types.InlineKeyboardMarkup()
  34.     url_button = types.InlineKeyboardButton(text="HelpDesk ", url="https://helpdesk")
  35.     keyboard.add(url_button)
  36.     bot.send_message(message.chat.id, "Привет! Нажми на кнопку и перейди в СервисДеск.", reply_markup=keyboard)
  37.  
  38.  
  39.  
  40. bot.polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement