def run(self): download = [] self.get_user_name() exist = data.session.query(data.User).filter(data.User.vk_id == self.user_id).first() if not exist: self.user = data.User(vk_id=self.user_id, first_name=self.first_name, last_name=self.last_name) data.add_user(self.user) else: self.user = exist self.get_city() self.get_min_age() self.get_max_age() self.get_sex() self.find_user() for users in self.users_list: Found_User = FoundUser(users, self.user.id) download.append(data.FoundUser(vk_id=Found_User.vk_id, first_name=Found_User.first_name, last_name=Found_User.last_name, top_photos=Found_User.top_photos, User_id=Found_User.User_id, like=Found_User.like)) write_msg(self.user_id, CONTINUE_FIND_MESSAGE) for new_event in longpoll.listen(): if new_event.type == VkEventType.MESSAGE_NEW and new_event.to_me: if new_event.message.lower() == 'да': break if new_event.message.lower() == 'нет': data.add_user_list(download) self.get_json(data.session.query(data.FoundUser).filter(data.FoundUser.User_id == self.user.id).all()) return self.new_message('привет')
def add_users(): print("Got It") if request.method == 'POST': print("its post") print(request.form['email']) data.add_user(request.form['email'], request.form['password']) return redirect('/users')
async def on_message(self, message): if message.author == self.disclient.user: return if message.author.bot: return author = str(message.author.id) found = find_user(author) if not found: add_user(author) add_user_xp(author)
def post(self): secret = self.request.get('secret') nickname = self.request.get('nickname') user = users.get_current_user() uid = user.user_id() try: data.get_user_by_id(uid) data.update_user(uid, secret, nickname) except data.UserException: data.add_user(uid, user.email(), secret, nickname) self.redirect('/list')
def create_user(): response = {} username = request.form.get("username") password = request.form.get("password") pw_hash = bcrypt.generate_password_hash(password) pw_hash = pw_hash.decode('utf8') try: # Connect to database and create a new user if doesn't already exist results = db.execute("Select * from user").fetchall() print(results) user_id = add_user(db, username, pw_hash) session['username'] = username session['logged_in'] = True session['user_id'] = user_id # Adding details to the response to be sent back response['success'] = True response['message'] = 'Registered successfully!' response['username'] = username return jsonify(response) except UserExistsError as e: response['success'] = False response['message'] = 'Username taken, please use some other username!' return jsonify(response)
def create_user(response=None): if not response: response = flask.make_response() form_data = flask.request.form try: data.add_user( form_data['username'], form_data['password'], form_data['first_name'], form_data['last_name'], form_data['email'], ) set_current_user(form_data, response) return response except Exception as e: raise UserCreationError('Unable to create user')
def start(bot: Bot, update: Update): user = update.message.from_user if user.username is None: update.message.reply_text( "Please set up a username and re-run /start to use this bot") return if user.id not in data.users: data.add_user( RUser(user.id, user.username, '', None, None, '', State.START)) else: data.users[user.id].state = State.START update.message.reply_text(config['start_messages'], reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("Got it!", callback_data="gotit"), ]]))
def owner_or_admin_guilds(authorization): userId = data.get_user_id(authorization) if userId: return json.loads(data.get_user_guilds(userId)) user = get_user(authorization) url = DISCORD_API_URL + "/users/@me/guilds" headers = {"authorization": authorization} result = requests.get(url, headers=headers) if result.status_code != 200 or not user: returnReqError(url, result) return None guilds = [ guild["id"] for guild in result.json() if guild["owner"] or (guild["permissions"] & 0x8) == 0x8 ] data.add_user(user["id"], user["username"], user["discriminator"], json.dumps(guilds)) data.add_user_token(authorization, user["id"]) return guilds
def signup_action(): if request.method == 'POST': print(request.form['email']) add_user(request.form['email'], request.form['password']) print("SignUp Action completed") return redirect('/signin')