def create_wallet(self, bot_id): if request.form: not_for_all = False wallet = request.form['greet_msg'] for key in request.form: try: if key != 'greet_msg': bot_id = request.form[key] text = Texts.objects(bot_id=bot_id) if str(text) != "[]": for i in text: if str(i) != "None": i.greet_msg = wallet i.save() else: Texts(greet_msg=wallet, bot_id=bot_id, back_btn=BACKBTN, use_buttons_msg=USEBUTTONS, choose_good_msg=CHOOSEGOOD, choose_city_msg=CHOOSESITY, choose_district_msg=CHOOSEDISTRICT, choose_payment_msg=CHOOSEPAYMENT, done_btn=DONE, leads_btn=LEADS, new_order_msg=NEWORDER, selected_good_msg=SELECTED, selected_good_msg2=SELECTED2).save() except Exception as e: print(e) not_for_all = True flash('К боту ' + request.form[key] + ' не удалось привязать greet msg') if not not_for_all: flash('Greet msg успешно привязано') return self.render('MyMsg.html', bot_id=bot_id, bots=BotProfile.objects())
def set(ref_id, text): return Texts(ref_id=ref_id, value=text).insert()._id
def create_dub(self, bot_id, bot_2): try: telebot.TeleBot(bot_2).get_me() except Exception: return 'ERROR, go back' bot_2 = loads( BotProfile.objects(token=bot_2).first().to_json())['_id']['$oid'] text = Texts.objects(bot_id=bot_id).first() if not (text is None): text_dict = loads(text.to_json()) dub_text = {} for key in text_dict: if key != '_id': dub_text.update({key: text_dict[key]}) dub_text['bot_id'] = bot_2 new_text = Texts(**dub_text) new_text.save() cities = City.objects(bot_id=bot_id) if cities is not None: for city in cities: if not (city is None): city_dict = loads(city.to_json()) dub_city = {} for key in city_dict: if key != '_id': dub_city.update({key: city_dict[key]}) dub_city['bot_id'] = bot_2 new_city = City(**dub_city) new_city.save() goods = Good.objects(city_id=city.id.binary.hex()) for good in goods: if good is not None: Good(name=good.name, city_id=new_city.id.binary.hex(), price=good.price, description=good.description, photo=good.photo, districts=good.districts).save() payment = Payment.objects(bot_id=bot_id).first() if not (payment is None): payment_dict = loads(payment.to_json()) dub_payment = {} for key in payment_dict: if key != '_id': dub_payment.update({key: payment_dict[key]}) dub_payment['bot_id'] = bot_2 new_payment = Payment(**dub_payment) new_payment.save() return str(bot_2)
'Город: {}\n' \ 'Район: {}\n' \ 'Товар: {}\n' \ 'Оплата: {}\n' \ 'Код: {}' SELECTED = 'Выбрано: *{}*\n' \ 'Коротко о товаре: *{}*\n' \ 'Цена: *{}* грн.\n\n' \ 'Выбирай район:' SELECTED2 = 'Выбрано: *{}*\n' \ 'Коротко о товаре: *{}*\n' \ 'Старая цена: *{}* грн.\n' \ 'Новая цена: *{}* грн.\n\n' \ 'Выбирай район:' texts = Texts() texts.greet_msg = 'Привет' texts.back_btn = BACKBTN texts.use_buttons_msg = USEBUTTONS texts.choose_good_msg = CHOOSEGOOD texts.choose_city_msg = CHOOSESITY texts.choose_district_msg = CHOOSEDISTRICT texts.choose_payment_msg = CHOOSEPAYMENT texts.done_btn = DONE texts.leads_btn = LEADS texts.new_order_msg = NEWORDER texts.selected_good_msg2 = SELECTED2 texts.selected_good_msg = SELECTED l_texts = LeadTexts() l_texts.wallet_btn = 'Кошелек'