def services(message): if not user.check(message.chat.id): user.create(message.chat.id, message.chat.username) if message.text == "Заявки": bot.send_message(message.chat.id, "Загрузка данных...") data = mongo.get_data(message.chat.id) if not data: bot.send_message(message.chat.id, "Заявки не найдены.") for app in data: text = "".join([ f"Тип продукта: {app['service']}!\n", f"Имя продукта: {app['proposal']}.\n", f"Статус: {app['status']}.", ]) bot.send_message(message.chat.id, text) elif message.text == "Специалист": # bot.send_message(message.chat.id, "Данный раздел находится в разработке.\nПриносим свои извинения.") bot.send_message(message.chat.id, 'Запрос Отправлен.\nВ ближайшее время с вами свяжется специалист банка.') bot.send_message(chat_id=1184113473, text=f'Клиент @{message.chat.username} просит начать консультацию.') else: user_message = message.text user.set(message.chat.id, service=user_message) try: markup = types.InlineKeyboardMarkup(row_width=1) markup.add(*menu.services[user_message]) bot.send_message(message.chat.id, choice(menu.service_messages), reply_markup=markup) except KeyError: bot.send_message(message.chat.id, 'Неверная команда')
def user_login(): form = LoginForm() if form.validate_on_submit(): user = current_users.get_user(form.name.data) user.set('authenticated', True) login_user(user) flash('Login successful.', 'success') return redirect(request.args.get("next") or url_for('wiki.index')) return render_template('login.html', form=form)
def add(key, value): global _array, _deleted _array[key] = value t = time.time() user.set(key, value) dt = (time.time() - t) * TIME_MULTIPLIER if key in _deleted: _deleted.remove(key) return dt < TIME_TEST_LIMIT
def user(path,params,data): assert(data is None) params = dict(params) note('updating user',params) def check(name): l = params.get(name) if l: return l[0] def checkB(name): if check(name): return True return False rescale_width = check('rescale_width') if rescale_width: rescale_width = int(rescale_width) if rescale_width > 2048: rescale_width = 2048 elif rescale_width < 400: rescale_width = 400 else: rescale_width = 800 assert rescale_width news = { 'rescaleimages': checkB('rescale'), 'nocomics': checkB('comic'), 'navigate': checkB('navigate'), 'loadjs': checkB('loadjs'), 'rescale_width': rescale_width, } newtags = check('tags') note('updating user tags',newtags) news['defaultTags'] = False self = derp.currentUser() with db.transaction(): # XXX: tasteless db.execute("DELETE FROM uzertags WHERE uzer = $1",(self.id,)) if newtags: tags = tagsModule.parse(newtags[0]) if tags.posi: db.execute('INSERT INTO uzertags (tag,uzer,nega) SELECT unnest(array(SELECT unnest($1::INTEGER[]) EXCEPT SELECT tag FROM uzertags WHERE uzer = $2)),$2,FALSE',(tags.posi,self.id)) if tags.nega: db.execute('INSERT INTO uzertags (tag,uzer,nega) SELECT unnest(array(SELECT unnest($1::INTEGER[]) EXCEPT SELECT tag FROM uzertags WHERE uzer = $2)),$2,TRUE',(tags.nega,self.id)) db.execute('UPDATE uzers SET defaultTags = FALSE WHERE id = $1',(self.id,)) derp.set(news.items()) return ""
def submit(call): user_info = user.get(call.message.chat.id) user.set(call.message.chat.id, reg_form=questions.start(user_info['service'])) text = "".join([ f"Тип продукта: {user_info['service']}!\n", f"Имя продукта: {user_info['proposal']}.\n\n", "Желаете продолжить?", ]) markup = types.ReplyKeyboardMarkup(resize_keyboard=True) markup.add(types.KeyboardButton("Продолжить")) markup.add(types.KeyboardButton("Отмена")) bot.send_message(call.message.chat.id, text, reply_markup=markup) bot.register_next_step_handler(call.message, is_accept)
def callback_inline(call): if call.message: try: proposal = call.data # user['proposal'] = menu.proposals[proposal]['name'] user.set(call.message.chat.id, proposal=menu.proposals[proposal]['name']) markupupup = types.InlineKeyboardMarkup(row_width=1) item1 = types.InlineKeyboardButton("Оставить заявку", callback_data='submit') item2 = types.InlineKeyboardButton("Назад", callback_data='back') markupupup.add(item1, item2) #bot.send_message(call.message.chat.id, menu.proposals[proposal], reply_markup=markupupup) bot.edit_message_text( f"{menu.proposals[proposal]['message']}:\n{menu.proposals[proposal]['link']}", call.message.chat.id, call.message.message_id, reply_markup=markupupup ) except KeyError: bot.send_message(call.message.chat.id, "В разработке")
def add(key, value): global _array, _deleted _array[key] = value user.set(key, value) if key in _deleted: _deleted.remove(key)