Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- import Repairs
- import builder_config
- from telebot import types
- user_dict = {}
- class User:
- def __init__(self):
- self.length = None
- self.width = None
- self.heigth = None
- self.rollw = None
- self.rolll = None
- user = User
- answers = {'привет': 'Привет, великий строитель!',
- 'пока': 'Доброй дороги тебе в своих начинаниях',
- }
- def parse_str(string_ob):
- """Transforms string to list."""
- return string_ob.split()
- bot = telebot.TeleBot(builder_config.Token)
- keyboard1 = telebot.types.ReplyKeyboardMarkup(True)
- keyboard1.row('Посчитать обои',
- 'Сколько плитки')
- @bot.message_handler(commands=['start'])
- def start_message(message):
- bot.send_message(message.chat.id,
- 'Привет, это помошник для ведения ремонта.'
- '\nВыберите чем вам помочь:'
- '\nСколько обоев на комнату- Посчитать обои?'
- '\nСколько плитки на стены комнаты- Сколько плитки?',
- reply_markup=keyboard1)
- @bot.message_handler(content_types=['text'])
- def send_text(message):
- """Sends answers for the questions, returns str."""
- if 'привет' in message.text.lower():
- bot.send_message(message.chat.id, 'Привет, великий строитель!')
- elif 'пока' in message.text.lower():
- bot.send_message(message.chat.id,
- 'Доброй дороги тебе в своих начинаниях')
- elif 'трещин' and 'стен' in message.text.lower():
- bot.send_message(message.chat.id,
- 'Ваш фундамент дает осадку, нужно контролировать'
- ' ширину раскрытия трещины с помощью маяков. Если'
- ' трещина будет продолжать увеличиваться, то'
- ' обратитесь в проектную организацию. Если ширина'
- ' раскрытия трещины не увеличивается, то трещину'
- ' нужно инЪецировать или хотя бы замазать.')
- elif 'посчитать обои' in message.text.lower():
- bot.send_message(message.chat.id, 'Введите параметры комнаты в метрах:'
- '\nобоев длина ширина высота'
- ' ширина_рулона длина рулона'
- '\nпример: обоев 6 3 2.7 0.8 10')
- elif 'обоев' in message.text.lower():
- def process_length():
- chat_id = message.chat.id
- length = message.text
- user.length = length
- user_dict[chat_id] = user
- msg = bot.reply_to(message, 'Какая длина комнаты в метрах?')
- bot.register_next_step_handler(msg, process_width)
- def process_width():
- chat_id = message.chat.id
- width = message.text
- user.width = width
- user_dict[chat_id] = user
- msg = bot.reply_to(message, 'Какая высота комнаты в метрах?')
- bot.register_next_step_handler(msg, process_height)
- def process_height():
- chat_id = message.chat.id
- height = message.text
- user.height = height
- user_dict[chat_id] = user
- msg = bot.reply_to(message, 'Какая ширина рулона в метрах?')
- bot.register_next_step_handler(msg, process_rollw)
- def process_rollw():
- chat_id = message.chat.id
- rollw = message.text
- user.rollw = rollw
- user_dict[chat_id] = user
- msg = bot.reply_to(message, 'Какая длина рулона в метрах?')
- bot.register_next_step_handler(msg, process_rolll)
- def process_rolll():
- chat_id = message.chat.id
- rolll = message.text
- user.rolll = rolll
- user_dict[chat_id] = user
- count1 = Repairs.Room(float(user.length), float(user.width),
- float(user.height), float(user.rollw),
- float(user.rolll))
- bot.send_message(message.chat.id, count1.ruloni())
- # vars = parse_str(message.text.lower())
- # count1 = Repairs.Room(float(vars[1]), float(vars[2]),
- # float(vars[3]), float(vars[4]), float(vars[5]))
- # bot.send_message(message.chat.id, count1.ruloni())
- elif 'сколько плитки' in message.text.lower():
- bot.send_message(message.chat.id, 'Введите параметры комнаты в метрах:'
- '\nплитка длина ширина высота'
- ' ширина_плитки длина плитки'
- '\nпример: плитка 6 3 2.7 0.8 10')
- elif 'плитка' in message.text.lower():
- vars = parse_str(message.text.lower())
- count1 = Repairs.Room(float(vars[1]), float(vars[2]),
- float(vars[3]), float(vars[4]), float(vars[5]))
- bot.send_message(message.chat.id, count1.tiles())
- else:
- bot.send_message(message.chat.id, 'Неверный ввод, я Вас не понял.')
- bot.polling()
Add Comment
Please, Sign In to add comment