Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 8.56 KB | None | 0 0
  1. import telebot
  2. from telebot import types
  3. bot = telebot.TeleBot('тут токен')
  4.  
  5. def anketa(message):
  6.     bot.send_message(message.from_user.id, "Как тебя зовут?")
  7.     bot.register_next_step_handler(message, get_name)
  8.     def get_name(message): #получаем фамилию
  9.         global name;
  10.         name = message.text;
  11.         bot.send_message(message.from_user.id, 'Какая у тебя фамилия?');
  12.         bot.register_next_step_handler(message, get_surnme);
  13.  
  14.     def get_surname(message):
  15.         global surname;
  16.         surname = message.text;
  17.         bot.send_message('Сколько тебе лет?');
  18.         bot.register_next_step_handler(message, get_age);
  19.  
  20.     def get_age(message):
  21.         global age;
  22.         while age == 0: #проверяем что возраст изменился
  23.             try:
  24.                  age = int(message.text) #проверяем, что возраст введен корректно
  25.             except Exception:
  26.                  bot.send_message(message.from_user.id, 'Цифрами, пожалуйста');
  27.           bot.send_message(message.from_user.id, 'Тебе '+str(age)+' лет, тебя зовут '+name+' '+surname+'?')
  28.  
  29.  
  30.  
  31. def ku(call):
  32.     typework = types.InlineKeyboardMarkup()
  33.     msg = 'Выберите тип услуги: \n'
  34.     global poddone
  35.     global podd
  36.     global genwork
  37.     global afterwork
  38.     global afterwork20
  39.     global vipwork
  40.     podd = types.InlineKeyboardButton(text = 'Поддерживающая уборка (Постоянный клиент) - ' + pricepodd, callback_data = 'poddpost')
  41.     global msgepodd
  42.     msgepodd = podd.text
  43.     typework.add(podd)
  44.     poddone = types.InlineKeyboardButton(text = 'Поддерживающая уборка (разовый заказ) - ' + pricepoddone, callback_data = 'poddone')
  45.     typework.add(poddone)
  46.     global msgepoddone
  47.     msgepoddone = poddone.text
  48.     genwork = types.InlineKeyboardButton(text = 'Генеральнная уборка - ' + pricegen, callback_data = 'genwork')
  49.     typework.add(genwork)
  50.     global genworktext
  51.     genworktext = genwork.text
  52.     afterwork20 = types.InlineKeyboardButton(text = 'Уборка после ремонта (Без мебели — скидка 20%)', callback_data = 'afterwork20')
  53.     typework.add(afterwork20)
  54.     global afterwork20text
  55.     afterwork20text = afterwork20.text
  56.     afterwork = types.InlineKeyboardButton(text = 'Уборка после ремонта с мебелью - ' +priceafter, callback_data = 'afterdefault')
  57.     typework.add(afterwork)
  58.     global afterworktext
  59.     afterworktext = afterwork.text
  60.     vipwork = types.InlineKeyboardButton(text = 'VIP уборка - ' +pricevip, callback_data = 'vip')
  61.     typework.add(vipwork)
  62.     global vipworktxt
  63.     vipworktxt = vipwork.text
  64.     bot.send_message(call.message.chat.id, msg, reply_markup = typework )
  65.  
  66. def end(call):
  67.     if call.data == 'poddpost':
  68.         msg = 'Вы выбрали: ' + podd.text + '\n'
  69.        
  70.        
  71.  
  72. @bot.message_handler(content_types=["text"])
  73.  
  74. def welcome(message):
  75.  
  76.     button = types.InlineKeyboardMarkup() #объявление кнопок
  77.     #Уборка квартир
  78.     kvartirb = types.InlineKeyboardButton(text='Уборка квартир', callback_data='kvartir')
  79.     button.add(kvartirb) # add button to keyboard
  80.     #Уборка коттеджей
  81.     kottedj = types.InlineKeyboardButton(text = 'Уборка коттеджей', callback_data = 'kottedj')
  82.     button.add(kottedj) # add button to keyboard
  83.     #Уборка офисов и других помещений
  84.     other = types.InlineKeyboardButton(text = 'Уборка офисов и других помещений', callback_data = 'other')
  85.     button.add(other) # add button to keyboard
  86.     ###
  87.     welcometext = 'Здравствуйте, вас приветствует клининговая компания "ПрофКлинингСервис".\n'
  88.     welcometext += 'Выберите интересующий вас раздел.\n'
  89.     msg = bot.send_message(message.chat.id, welcometext, reply_markup=button)
  90.  
  91.  
  92.  
  93.     bot.register_next_step_handler(msg, callback_worker)
  94.  
  95.  
  96. @bot.callback_query_handler(func=lambda call: True)
  97.  
  98.  
  99.  
  100.  
  101. def callback_worker(call):
  102.     ploshad = 'Выберите соответствующую площадь квартиры: \n'
  103.     ploshadb = types.InlineKeyboardMarkup()
  104.     global pricepodd
  105.     global pricepoddone
  106.     global pricegen
  107.     global priceafter20
  108.     global priceafter
  109.     global pricevip
  110.     pricepodd = ''
  111.     pricepoddone = ''
  112.     pricegen = ''
  113.     priceafter = ''
  114.     priceafter20 = ''
  115.     pricevip = ''  
  116.     if call.data == 'kvartir':
  117.  
  118.         #до 40 кв.м
  119.         m40 = types.InlineKeyboardButton(text = 'До 40 кв.м', callback_data = 'metr40k')
  120.         ploshadb.add(m40)
  121.         #до 50 кв.м
  122.         m50 = types.InlineKeyboardButton(text = 'До 50 кв.м', callback_data = 'metr50k')
  123.         ploshadb.add(m50)
  124.         #до 60 кв.м
  125.         m60 = types.InlineKeyboardButton(text = 'До 60 кв.м', callback_data = 'metr60k')
  126.         ploshadb.add(m60)
  127.         #до 70кв.м
  128.         m70 = types.InlineKeyboardButton(text = 'До 70 кв.м', callback_data = 'metr70k')
  129.         ploshadb.add(m70)
  130.         #до 80 кв.м
  131.         m80 = types.InlineKeyboardButton(text = 'До 80 кв.м', callback_data = 'metr80k')
  132.         ploshadb.add(m80)
  133.         #до 90кв.м
  134.         m90 = types.InlineKeyboardButton(text = 'До 90 кв.м', callback_data = 'metr90k')
  135.         ploshadb.add(m90)
  136.         #до 100 кв.м
  137.         m100 = types.InlineKeyboardButton(text = 'До 100 кв.м', callback_data = 'metr100k')
  138.         ploshadb.add(m100)
  139.         #далее
  140.         other = types.InlineKeyboardButton(text = 'От 100 кв.м', callback_data = 'otherk')
  141.         ploshadb.add(other)
  142.         bot.send_message(call.message.chat.id, ploshad, reply_markup = ploshadb)
  143.        
  144.  
  145.  
  146.     if call.data == 'metr40k':
  147.         choises = True
  148.         pricepodd = '1 600 рублей'
  149.         pricepoddone = '2 300 рублей'
  150.         pricegen = '5 500 рублей'
  151.         priceafter20 = ''
  152.         priceafter = '6 500 рублей'
  153.         pricevip = '12 000 рублей'
  154.         ku(call)
  155.     elif call.data == 'metr50k':
  156.         choises = True
  157.         pricepodd = '1 800 рублей'
  158.         pricepoddone = '2 500 рублей'
  159.         pricegen = '5 500 рублей'
  160.         priceafter20 = ''
  161.         priceafter = '6 500 рублей'
  162.         pricevip = '12 000 рублей'
  163.         ku(call)
  164.     if call.data == 'metr60k':
  165.         choises = True
  166.         pricepodd = '1 800 рублей'
  167.         pricepoddone = '2 500 рублей'
  168.         pricegen = '7 000 рублей'
  169.         priceafter20 = '6 800 рублей'
  170.         priceafter = '8 500 рублей'
  171.         pricevip = '17 500 рублей'
  172.         ku(call)
  173.     elif call.data == 'metr70k':
  174.         choises = True
  175.         pricepodd = '1 900 рублей'
  176.         pricepoddone = '2 500 рублей'
  177.         pricegen = '8 000 рублей'
  178.         priceafter20 = '7 200 рублей'
  179.         priceafter = '9 000 рублей'
  180.         pricevip = '20 500 рублей'
  181.         ku(call)
  182.     if call.data == 'metr80k':
  183.         choises = True
  184.         pricepodd = '2 300 рублей'
  185.         pricepoddone = '2 600 рублей'
  186.         pricegen = '9 000 рублей'
  187.         priceafter20 = '7 600'
  188.         priceafter = '9 500 рублей'
  189.         pricevip = '23 500 рублей'
  190.         ku(call)
  191.     elif call.data == 'metr90k':
  192.         choises = True
  193.         pricepodd = '2 500 рублей'
  194.         pricepoddone = '3 000 рублей'
  195.         pricegen = '10 000 рублей'
  196.         priceafter20 = '8 400 рублей'
  197.         priceafter = '10 500 рублей'
  198.         pricevip = '26 500 рублей'
  199.         ku(call)
  200.     if call.data == 'metr100k':
  201.         choises = True
  202.         pricepodd = '2 500 рублей'
  203.         pricepoddone = '3 000 рублей'
  204.         pricegen = '11 000 рублей'
  205.         priceafter20 = '8 800 рублей'
  206.         priceafter = '11 000 рублей'
  207.         pricevip = '29 000 рублей'
  208.         ku(call)
  209.     elif call.data == 'otherk':
  210.         choises = True
  211.         pricepodd = '24 р/кв.м'
  212.         pricepoddone = '30р/кв.м'
  213.         pricegen = '110р/кв.м'
  214.         priceafter20 = '88р/кв.м'
  215.         priceafter = '110р/кв.м'
  216.         pricevip = '290р/кв.м'
  217.         ku(call)
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242. bot.polling( none_stop = True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement