def unique_product(call): """ send a message with instruction of unique product """ txt = utils.txt_size() bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text = txt) worker_db.set_state(call.from_user.id, config.States.SIZE.value)
def pick_material(message): """ user picks a material for a unique order """ #7 - is id of a unique product logging.info("In the UNIQUE_MATERIAL") in_kb, txt = utils.in_kb_materials(7, "order") bot.send_message(message.chat.id, text = txt, reply_markup = in_kb) worker_db.set_state(message.chat.id, config.States.START.value)
def get_name_material(message): """ getting name of the material and put in db """ if message.text != '0': txt = utils.add_material(message.text) bot.send_message(message.chat.id, text = txt) else: bot.send_message(message.chat.id, text = "Материал не был добавлен") worker_db.set_state(message.chat.id, config.States.START.value)
def add_material(message): """ Let user add material as a writing text """ #handle permissons for adm user_id = message.from_user.id if utils.perm_adm(user_id) == 1: bot.send_message(message.chat.id, text = "Напишите имя нового материала.\ Если Вы нажали сбда случайно напишите '0'") worker_db.set_state(message.chat.id, config.States.ADD_MATERIAL.value) else: bot.send_message(message.chat.id, text = "У Вас нету доступа к этой функции")
def receive_material(call): """ show a in_kb of materials """ id_info = re.findall(r"\d+", call.data) id_material = id_info[0] db = SQLbase(config.db) db.add_material_term_receive(id_material) db.close() worker_db.set_state(call.from_user.id, config.States.RECEIVE_P_M.value) txt_1 = "Теперь напишите погонный метр(п.м.)" txt_2 = "Пример: 50.30" txt_3 = "Используйте '.'! Не верно: 50,30" txt = "{}\n{}\n{}".format(txt_1, txt_2, txt_3) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text = txt)
def write_p_m(message): """ Adm or shop writing a p_m of a unique product """ try: p_m = float(message.text) except: p_m = None if p_m == None: txt = "Вы ввели не правильное число для п.м.! Используйте целое число(Например: 4) или число с точкой (Например: 4.30)" bot.send_message(message.chat.id, text = txt) return else: #add_p_m to table Unique_term db = SQLbase(config.db) db.add_item_unique('p_m', p_m) db.close() worker_db.set_state(message.chat.id, config.States.UNIQUE_MATERIAL.value) pick_material(message)
def write_size(message): """ Adm or shop writing a size of a unique product """ logging.info(message.text) if message.text == "0": bot.send_message(message.chat.id, text = "Вы прекратили заполнять заявку на произвольный размер.") worker_db.set_state(message.chat.id, config.States.START.value) return try: index = message.text.index('*') except: index = None logging.info(index) check, txt = utils.check_size(message.text, index) if check == 0: bot.send_message(message.chat.id, text = txt) return else: bot.send_message(message.chat.id, text = txt) worker_db.set_state(message.chat.id, config.States.P_M.value)
def receive_p_m(message): try: p_m = float(message.text) except: p_m = None if p_m == None: txt = "Вы ввели не правильное число для п.м.! Используйте целое число(Например: 50) или число с точкой (Например: 50.30)" bot.send_message(message.chat.id, text = txt) return else: #add_p_m to table Unique_term db = SQLbase(config.db) db.add_p_m_term_receive(p_m) id_material, p_m = db.term_receive_info() db.add_receive(p_m, id_material) material = db.info_material(id_material) db.close() txt = "Вы добавили ткань материала: {}. И размером {} п.м.".format(material, p_m) worker_db.set_state(message.chat.id, config.States.START.value) bot.send_message(message.chat.id, text = txt)