def users_add(): user_data = request.form.to_dict() user_data['create_time'] = datetime.now() user_data['last_time'] = datetime.now() error = db.user_regedit_check(user_data) if error['status'] == 0: db.user_add(user_data) return json.dumps(error)
def users_add(): user_data = request.form.to_dict() user_data['create_time'] = datetime.now() user_data['last_time'] = datetime.now() user_data['password'] = db.calc_md5(user_data['password']) user_data['repwd'] = db.calc_md5(user_data['repwd']) error = db.user_regedit_check(user_data) if error['status'] == 0: db.user_add(user_data) util.WriteLog('infoLogger').warning('%s add user %s' % (session['username'], user_data['name'])) return json.dumps(error)
def users_add(): user_data = request.form.to_dict() user_data['create_time'] = datetime.now() user_data['last_time'] = datetime.now() user_data['password'] = db.calc_md5(user_data['password']) user_data['repwd'] = db.calc_md5(user_data['repwd']) error = db.user_regedit_check(user_data) if error['status'] == 0: db.user_add(user_data) util.WriteLog('infoLogger').warning( '%s add user %s' % (session['username'], user_data['name'])) return json.dumps(error)
def add_user(name, email, passwd, real_name): pwhash = yield threads.deferToThread(_hash_passwd_thread, passwd, bcrypt.gensalt()) user_id = yield db.user_add(name, email, pwhash, real_name, admin.Level.user) for chid in global_.channels.get_default_channels(): yield db.channel_add_user(chid, user_id) defer.returnValue(user_id)
def users_add(): user_data = request.form.to_dict() user_data['create_time'] = datetime.now() user_data['last_time'] = datetime.now() flag, error = db.user_regedit_check(user_data) if flag: if db.user_add(user_data): return redirect('/users/userinfo?name=%s' % user_data['name']) return render_template('user_create.html', result=error)
def users_add(): params = request.form username = params.get('username') password = params.get('password') name_cn = params.get('name_cn') email = params.get('email') mobile = params.get('mobile') role = params.get('role') status = params.get('status') create_time = datetime.now() last_time = datetime.now() if db.user_regedit_check(username,password,name_cn,email,mobile,role,status,create_time,last_time): if db.user_add(username,password,name_cn,email,mobile,role,status,create_time,last_time): return redirect('/users') return redirect('/users/regedit/')
def users_add(): params = request.form username = params.get('username') password = params.get('password') name_cn = params.get('name_cn') email = params.get('email') mobile = params.get('mobile') role = params.get('role') status = params.get('status') create_time = datetime.now() last_time = datetime.now() if db.user_regedit_check(username, password, name_cn, email, mobile, role, status, create_time, last_time): if db.user_add(username, password, name_cn, email, mobile, role, status, create_time, last_time): return redirect('/users') return redirect('/users/regedit/')
def add(): name = request.args.get('name') passwd = request.args.get('passwd') error_info = "" if name == "" or passwd == "": error_info = "name or password is empty." else: result_code = db.user_add(name, passwd) if result_code == -1: error_info = "db error!" elif result_code == 0: error_info = "changed %s's password." % name else: # 1 error_info= "%s has been added." % name # url_for ?error_info=str red_url = url_for('index', error_info=error_info) return redirect(red_url)
def add(): name = request.args.get('name') passwd = request.args.get('passwd') error_info = "%s has added succussfully." % name # 1: ok ; 0: error status_code = 1 # if name == "" or passwd == "": 前端可以做,后端也要做 # 前后端都要做数据校验 if name == "" or passwd == "": error_info = "name or password is empty." status_code = 0 else: result_code = db.user_add(name, passwd) if result_code == -1: error_info = "db error!" status_code = 0 elif result_code == 0: error_info = "changed %s's password." % name status_code = 1 else: # 1 error_info = "%s has been added." % name status_code = 1 res_status_tuple = ("res_status", error_info, status_code) # url_for ?error_info=str # red_url = url_for('index', error_info=error_info) # return redirect(red_url) res_tuple = db.select_all() res_list = list(res_tuple) res_list.insert(0, res_status_tuple) res_json = json.dumps(res_list) # print "*" * 20 # print res_json # print "*" * 20 return res_json
def add(): name = request.args.get('name') passwd = request.args.get('passwd') error_info = "%s has added succussfully." % name # 1: ok ; 0: error status_code = 1 # if name == "" or passwd == "": 前端可以做,后端也要做 # 前后端都要做数据校验 if name == "" or passwd == "": error_info = "name or password is empty." status_code = 0 else: result_code = db.user_add(name, passwd) if result_code == -1: error_info = "db error!" status_code = 0 elif result_code == 0: error_info = "changed %s's password." % name status_code = 1 else: # 1 error_info= "%s has been added." % name status_code = 1 res_status_tuple = ("res_status", error_info, status_code) # url_for ?error_info=str # red_url = url_for('index', error_info=error_info) # return redirect(red_url) res_tuple = db.select_all() res_list = list(res_tuple) res_list.insert(0, res_status_tuple) res_json = json.dumps(res_list) # print "*" * 20 # print res_json # print "*" * 20 return res_json
async def on_message(message): prefixes = ['<@!{}>'.format(client.user.id), '@lilac', 'l,'] # Shortcut functions for the sake of readability def parse(msg): return msg.split() def checkfor(*matches): args = parse(message.content) if len( args ) > 0: # Sometimes lilac's embeds are detected as empty messages, which throws an IndexError without this line if args[0].lower() in prefixes: if args[1] in matches: return True if dev: if message.content == 'gen': users = list(client.get_all_members()) for i in users: if i.mention.startswith('<@!'): continue # Skip bot accounts userobj = await client.get_user_info(i.mention[2:-1]) print(userobj.id) print(userobj.name + userobj.discriminator) user = userobj.name + userobj.discriminator db.create_id_reference(userobj.id, user) if checkfor('r', 'return'): print('message.content') print(message.content) print('cleaned message') print(message.clean_content) await client.send_message(message.channel, "Message returned.") if checkfor('scoreboard'): await client.send_typing(message.channel) await client.send_message( message.channel, "ℹ View all scores here: https://alpha-hedge.github.io/dogspotter-scoreboard" ) if checkfor('help'): await client.send_typing(message.channel) await client.send_message( message.channel, "ℹ All Lilac commands are here: https://alpha-hedge.github.io/dogspotter-scoreboard/lilac2/index.html" ) # Score commands if checkfor('score'): # Parse message for processing args = parse(message.content) # Get user object from mentions try: userobj = await client.get_user_info(message.raw_mentions[0]) if userobj.id == client.user.id: userobj = await client.get_user_info(message.raw_mentions[1]) except IndexError: if 'me' in args: userobj = message.author else: await client.send_message(message.channel, "⚠ No user tag found.") user = userobj.name + userobj.discriminator db.user_add(userobj.id, user, userobj.name) # reading score if args[2] == ('read') or args[2] == ('get'): print('\n[' + Style.BRIGHT + Fore.BLUE + db.timestamp() + '] message trigger:' + Style.RESET_ALL) print(message.clean_content) await client.send_typing(message.channel) embed = discord.Embed(title="ℹ️ Current User Score", description="Current score of {}:".format( userobj.name), color=0xff00ff) embed.set_author(name="Lilac", icon_url='') embed.add_field(name="Season:", value=str(db.score_get(userobj.id)['points']), inline=False) embed.add_field(name="All-time:", value=str(db.score_get(userobj.id)['allpts']), inline=False) await client.send_message(message.channel, embed=embed) # changing score elif args[2] == 'update' or args[2] == 'change': print('\n' + Style.BRIGHT + Fore.BLUE + '[' + db.timestamp() + '] message trigger:' + Style.RESET_ALL) print(message.clean_content) await client.send_typing(message.channel) for i in args: try: amount = int(i) break except ValueError: continue before = db.score_get(userobj.id)['points'] try: after = db.score_update(userobj.id, int(amount))['points'] embed = discord.Embed( title="✅ Score Updated", description="Score of {} was updated.".format( userobj.name), color=0xff00ff) embed.set_author(name="Lilac", icon_url='') embed.add_field(name="Was:", value=str(before), inline=False) embed.add_field(name="Now:", value=str(after), inline=False) await client.send_message(message.channel, embed=embed) except ValueError: await client.send_message( message.channel, "⚠️ No number found in message.".format(amount)) else: await client.send_message( message.channel, "⚠️ No valid command was given after 'score'.") if dev: if message.content == 'lq': print('Quitting...') exit()