sttpforever

Untitled

Mar 21st, 2021
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.80 KB | None | 0 0
  1. import telebot
  2.  
  3. import Repairs
  4.  
  5. import builder_config
  6.  
  7. from telebot import types
  8.  
  9. user_dict = {}
  10.  
  11.  
  12. class User:
  13. def __init__(self):
  14. self.length = None
  15. self.width = None
  16. self.heigth = None
  17. self.rollw = None
  18. self.rolll = None
  19.  
  20.  
  21. user = User
  22. answers = {'привет': 'Привет, великий строитель!',
  23. 'пока': 'Доброй дороги тебе в своих начинаниях',
  24. }
  25.  
  26.  
  27. def parse_str(string_ob):
  28. """Transforms string to list."""
  29. return string_ob.split()
  30.  
  31.  
  32. bot = telebot.TeleBot(builder_config.Token)
  33.  
  34.  
  35. keyboard1 = telebot.types.ReplyKeyboardMarkup(True)
  36. keyboard1.row('Посчитать обои',
  37. 'Сколько плитки')
  38.  
  39.  
  40. @bot.message_handler(commands=['start'])
  41. def start_message(message):
  42. bot.send_message(message.chat.id,
  43. 'Привет, это помошник для ведения ремонта.'
  44. '\nВыберите чем вам помочь:'
  45. '\nСколько обоев на комнату- Посчитать обои?'
  46. '\nСколько плитки на стены комнаты- Сколько плитки?',
  47. reply_markup=keyboard1)
  48.  
  49.  
  50. @bot.message_handler(content_types=['text'])
  51. def send_text(message):
  52. """Sends answers for the questions, returns str."""
  53. if 'привет' in message.text.lower():
  54. bot.send_message(message.chat.id, 'Привет, великий строитель!')
  55. elif 'пока' in message.text.lower():
  56. bot.send_message(message.chat.id,
  57. 'Доброй дороги тебе в своих начинаниях')
  58. elif 'трещин' and 'стен' in message.text.lower():
  59. bot.send_message(message.chat.id,
  60. 'Ваш фундамент дает осадку, нужно контролировать'
  61. ' ширину раскрытия трещины с помощью маяков. Если'
  62. ' трещина будет продолжать увеличиваться, то'
  63. ' обратитесь в проектную организацию. Если ширина'
  64. ' раскрытия трещины не увеличивается, то трещину'
  65. ' нужно инЪецировать или хотя бы замазать.')
  66. elif 'посчитать обои' in message.text.lower():
  67. bot.send_message(message.chat.id, 'Введите параметры комнаты в метрах:'
  68. '\nобоев длина ширина высота'
  69. ' ширина_рулона длина рулона'
  70. '\nпример: обоев 6 3 2.7 0.8 10')
  71. elif 'обоев' in message.text.lower():
  72. def process_length():
  73. chat_id = message.chat.id
  74. length = message.text
  75. user.length = length
  76. user_dict[chat_id] = user
  77. msg = bot.reply_to(message, 'Какая длина комнаты в метрах?')
  78. bot.register_next_step_handler(msg, process_width)
  79.  
  80. def process_width():
  81. chat_id = message.chat.id
  82. width = message.text
  83. user.width = width
  84. user_dict[chat_id] = user
  85. msg = bot.reply_to(message, 'Какая высота комнаты в метрах?')
  86. bot.register_next_step_handler(msg, process_height)
  87.  
  88. def process_height():
  89. chat_id = message.chat.id
  90. height = message.text
  91. user.height = height
  92. user_dict[chat_id] = user
  93. msg = bot.reply_to(message, 'Какая ширина рулона в метрах?')
  94. bot.register_next_step_handler(msg, process_rollw)
  95.  
  96. def process_rollw():
  97. chat_id = message.chat.id
  98. rollw = message.text
  99. user.rollw = rollw
  100. user_dict[chat_id] = user
  101. msg = bot.reply_to(message, 'Какая длина рулона в метрах?')
  102. bot.register_next_step_handler(msg, process_rolll)
  103.  
  104. def process_rolll():
  105. chat_id = message.chat.id
  106. rolll = message.text
  107. user.rolll = rolll
  108. user_dict[chat_id] = user
  109. count1 = Repairs.Room(float(user.length), float(user.width),
  110. float(user.height), float(user.rollw),
  111. float(user.rolll))
  112. bot.send_message(message.chat.id, count1.ruloni())
  113.  
  114. # vars = parse_str(message.text.lower())
  115. # count1 = Repairs.Room(float(vars[1]), float(vars[2]),
  116. # float(vars[3]), float(vars[4]), float(vars[5]))
  117. # bot.send_message(message.chat.id, count1.ruloni())
  118. elif 'сколько плитки' in message.text.lower():
  119. bot.send_message(message.chat.id, 'Введите параметры комнаты в метрах:'
  120. '\nплитка длина ширина высота'
  121. ' ширина_плитки длина плитки'
  122. '\nпример: плитка 6 3 2.7 0.8 10')
  123. elif 'плитка' in message.text.lower():
  124. vars = parse_str(message.text.lower())
  125. count1 = Repairs.Room(float(vars[1]), float(vars[2]),
  126. float(vars[3]), float(vars[4]), float(vars[5]))
  127. bot.send_message(message.chat.id, count1.tiles())
  128. else:
  129. bot.send_message(message.chat.id, 'Неверный ввод, я Вас не понял.')
  130.  
  131.  
  132. bot.polling()
Add Comment
Please, Sign In to add comment