Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. import telebot
  2. import config
  3. from telebot import types
  4.  
  5. bot = telebot.TeleBot(config.token)
  6.  
  7. AllKeyboard = types.ReplyKeyboardMarkup(resize_keyboard=True,one_time_keyboard=False)
  8. AllKeyboard.row('Сoздaть обрaщeниe')
  9. AllKeyboard.row('Пoсмoтреть другиe уcлуги')
  10.  
  11.  
  12. CellPhoneSendKeyboard = types.ReplyKeyboardMarkup(resize_keyboard=True,one_time_keyboard=False)
  13. button_phone = types.KeyboardButton(text="Отправить номер телефона", request_contact=True)
  14. CellPhoneSendKeyboard.add(button_phone)
  15.  
  16. SendFullName = types.ReplyKeyboardMarkup(resize_keyboard=True,one_time_keyboard=False)
  17. SendFullName.row('SEND')
  18.  
  19. HideKeyboard = types.ReplyKeyboardRemove()
  20.  
  21. CellPhoneRetryKeyboard = types.ReplyKeyboardMarkup(resize_keyboard=True,one_time_keyboard=False)
  22. button_phone = types.KeyboardButton(text="Отправить номер телефона", request_contact=True)
  23. CellPhoneRetryKeyboard.add(button_phone)
  24. CellPhoneRetryKeyboard.row('Пeрeйти в Глaвнoе мeню')
  25.  
  26. URLKeyboard = types.InlineKeyboardMarkup()
  27. TelecomURLBotton = types.InlineKeyboardButton(text="Перейти в Telecom.kz", url="https://telecom.kz/")
  28. URLKeyboard.add(TelecomURLBotton)
  29.  
  30. @bot.message_handler(content_types=["contact"])
  31. def test(message):
  32. try:
  33. bot.send_message(message.chat.id, config.message3, reply_markup=HideKeyboard)
  34. bot.register_next_step_handler(message,process_step)
  35. except:
  36. error_step_2(message)
  37.  
  38. def process_step(message):
  39. bot.send_message(message.chat.id, config.message4, reply_markup=AllKeyboard)
  40.  
  41. def error_step_1(message):
  42. bot.send_message(message.chat.id, config.message1, reply_markup=AllKeyboard)
  43.  
  44. def error_step_2(message):
  45. bot.send_message(message.chat.id, config.message5, reply_markup=CellPhoneRetryKeyboard)
  46.  
  47. class abot:
  48. @bot.message_handler(content_types=["text"])
  49. def reply_all_messages(self,message):
  50. unit_to_multiplier = {
  51. 'a': bot.send_message(message.chat.id, config.message1, reply_markup=AllKeyboard),
  52. 'b': bot.send_message(message.chat.id, config.message2, reply_markup=CellPhoneSendKeyboard),
  53. 'c': bot.send_message(message.chat.id,
  54. "Для ознакомления с другими услугами нажмите на кнопку «Перейти в Telecom.kz»",
  55. reply_markup=URLKeyboard)
  56. }
  57.  
  58. step = False
  59.  
  60. if message.text == '/start':
  61. self.unit_to_multiplier['a']
  62.  
  63. elif message.text == 'Сoздaть обрaщeниe':
  64. step = True
  65. self.unit_to_multiplier['b']
  66.  
  67. elif message.text == 'Пoсмoтреть другиe уcлуги':
  68. step = True
  69. self.unit_to_multiplier['c']
  70. else:
  71. print('точка')
  72. if step == False:
  73. error_step_1(message)
  74. else:
  75. error_step_2(message)
  76.  
  77.  
  78. if __name__=='__main__':
  79. bot.polling(none_stop=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement