def order(bot, telegram): message_id = select_menu(telegram).get('message_id') send_menu(bot, telegram, CHOOSE_GOOD, 11) try: del_menu(bot, telegram, message_id) except Exception as e: print(e)
def skip(bot, telegram): message_id = select_menu(telegram).get('message_id') send_menu(bot, telegram, THANKS_FOR_ORDER_OUT + '\n' + MAIN_MENU, 1) try: del_menu(bot, telegram, message_id) except Exception as e: print('error', e)
def instruction(bot, telegram): message_id = select_menu(telegram).get('message_id') send_menu(bot, telegram, NEED_HELP, 23) try: del_menu(bot, telegram, message_id) except Exception as e: print('error', e) return
def add_n_skip(bot, telegram): message_id = select_menu(telegram).get('message_id') send_menu(bot, telegram, ADD_GOOD, 22) try: del_menu(bot, telegram, message_id) except Exception as e: print(e) back_to_main_menu_del(bot, telegram)
def shop(bot, telegram): message_id = select_menu(telegram).get('message_id') # reply_message(bot, telegram, message_id, SELECT_PRODUCT, 16) send_menu(bot, telegram, SELECT_PRODUCT, 16) try: del_menu(bot, telegram, message_id) except Exception as e: print('error', e) if users.get(telegram): users.pop(telegram)
def payment_success(bot, telegram, summa): message_id = select_menu(telegram).get('message_id') send_menu(bot, telegram, WISHES, 10) try: del_menu(bot, telegram, message_id) except Exception as e: print(e) user = select_user(telegram) report_about_paid( USER_PAID.format(user.get('name'), summa, user.get('telegram'), user.get('phone')))
def news(bot, telegram): all_news = select_news() message_id = select_menu(telegram).get('message_id') if all_news == []: if telegram == 226665834: send_menu(bot, telegram, NEWS_EMPTY, 26) else: send_menu(bot, telegram, NEWS_EMPTY, 1) # reply_message(bot, telegram, message_id, NEWS_EMPTY, 1) else: new_text = '' all_news = all_news[::-1] last_news = [] total = 10 for new in all_news: last_news.append(new) total -= 1 if total == 0: break last_news = last_news[::-1] for new in last_news: new_text += NEW.format(new.get('new'), new.get('added')) if telegram == 226665834: send_menu(bot, telegram, new_text, 26) else: send_menu(bot, telegram, new_text, 1) try: del_menu(bot, telegram, message_id) except Exception as e: print('error', e) return
def basket(bot, telegram, message_id): orders = select_orders(telegram) message_id = select_menu(telegram).get('message_id') if orders == []: send_menu(bot, telegram, BAKEST_EMPTY, 11) try: del_menu(bot, telegram, message_id) except Exception as e: print('error', e) else: text = build_orders(orders[::-1]) # 'Корзина' send_menu(bot, telegram, text, 1) try: del_menu(bot, telegram, message_id) except Exception as e: print('error', e) return
def check_answer(bot, telegram, text): if check_user(telegram) == []: message_id = bot.send_message(telegram, NEED_PHONE_NUMBER, reply_markup=contact_menu()) users.update({telegram: {'mess_id': message_id.message_id}}) return True users_menu = select_menu(telegram) if users_menu.get('index') == 0: try: try: users[telegram].update(street=text) except Exception as e: return back_to_main_menu_del(bot, telegram) if users[telegram].get('min_sub'): show_confirm_sub_water(bot, telegram) if users[telegram].get('water'): confirm_menu(bot, telegram) except Exception as e: print('error', e) elif users_menu.get('index') == 10: try: users[telegram].update(comment=text) edit_report(users[telegram].get('report') + COMMENT.format(text)) skip(bot, telegram) except Exception as e: return back_to_main_menu_del(bot, telegram) elif users_menu.get('index') == 14: try: text = int(text) try: if users[telegram].get('min_sub') <= text: users[telegram].update(how_much_sub=text) show_sub_water(bot, telegram) else: text_send = 'Мало бутылок, <b>в абонементе %s</b> минимальное количество бутылей равно <b>%s</b>' % \ (users[telegram].get('term'), users[telegram].get('min_sub')) just_send_mes(bot, telegram, text_send) print('not enough water') except Exception as e: print(e) return back_to_main_menu_del(bot, telegram) except Exception as e: print('error', e) message_id = select_menu(telegram).get('message_id') try: send_menu( bot, telegram, CIN_PACK_WATER.format(users[telegram].get('price'), users[telegram].get('min_sub'), users[telegram].get('term')), 14) except Exception as e: return back_to_main_menu_del(bot, telegram) try: del_menu(bot, telegram, message_id) except Exception as e: print('error', e) elif users_menu.get('index') == 24: look_up_question(bot, telegram, text) elif users_menu.get('index') == 25: insert_news(telegram, text) back_to_main_menu_del(bot, telegram) all_users = select_all_users() print('all_users', all_users) print('text', text) for user in all_users: print('user', user) just_send_mes(bot, user.get('telegram'), 'Новости\n{}'.format(text)) elif users_menu.get('index') == 1: back_to_main_menu_del(bot, telegram)
def confirm_menu(bot, telegram): try: text_for_confirm = DATES_FOR_CONFIRM.format( users[telegram].get('name'), users[telegram].get('phone'), users[telegram].get('street')) except Exception as e: return back_to_main_menu_del(bot, telegram) total = 1 prices_productes = [] if users[telegram].get('water'): text_for_confirm += BOTTLE_FOR_CONFIRM.format( users[telegram].get('water'), product_price.get('water'), (users[telegram].get('water') * int(product_price.get('water')))) total = users[telegram].get('water') * int(product_price.get('water')) prices_productes.append( LabeledPrice(label='water', amount=int(users[telegram].get('water')) * int(product_price.get('water')) * 100)) if users[telegram].get('pompa'): text_for_confirm += POMPA_FOR_CONFIRM.format( users[telegram].get('pompa'), product_price.get('pompa'), (users[telegram].get('pompa') * int(product_price.get('pompa')))) total += users[telegram].get('pompa') * int(product_price.get('pompa')) prices_productes.append( LabeledPrice(label='pompa', amount=int(users[telegram].get('pompa')) * int(product_price.get('pompa')) * 100)) if users[telegram].get('pompaEL'): text_for_confirm += POMPA_FOR_CONFIRM.format( users[telegram].get('pompaEL'), product_price.get('pompaEL'), (users[telegram].get('pompaEL') * int(product_price.get('pompaEL')))) total += users[telegram].get('pompaEL') * int( product_price.get('pompaEL')) prices_productes.append( LabeledPrice(label='pompaEL', amount=int(users[telegram].get('pompaEL')) * int(product_price.get('pompaEL')) * 100)) if users[telegram].get('culer'): text_for_confirm += CULER_FOR_CONFIRM.format( users[telegram].get('culer'), product_price.get('culer'), (users[telegram].get('culer') * int(product_price.get('culer')))) total += users[telegram].get('culer') * int(product_price.get('culer')) prices_productes.append( LabeledPrice(label='culer', amount=int(users[telegram].get('culer')) * int(product_price.get('culer')) * 100)) prices.update({telegram: prices_productes}) text_for_confirm += ITOG_CONFIRM.format(total) # if first: try: del_menu(bot, telegram, select_menu(telegram).get('message_id')) except Exception as e: print(e) send_menu(bot, telegram, text_for_confirm, 8)