async def yobot_clan_statistics_api(group_id): bm = ue.get_bm(group_id) group = ue.get_group(bm) if group is None: return jsonify(code=20, message="Group dosen't exist") apikey = request.args.get('apikey') or 'apikey' return await ue.clan_statistics_api(bm, apikey)
async def yobot_user_info_api(uid): if 'yobot_user' not in session: return jsonify(code=10, message='未登录') user = ue.get_wm().get_user(session.get('yobot_user')) if user['uid'] != uid and not is_super_user(user['uid']): return jsonify(code=11, message='权限不足') user_data = ue.get_wm().get_user(uid) if user_data is None: return jsonify(code=20, message='用户不存在') member_data = ue.get_wm().get_member_by_uid(uid) clans = ue.get_wm().get_clan_by_uid(user['uid']) clan_name = {c['gid']: c['name'] for c in clans} if request.method == 'GET': return jsonify( code=0, userid=uid, authority_group=1 if is_super_user(user['uid']) else 100, last_login_time=user_data['last_login_time'], last_login_ipaddr=user_data['last_login_ipaddr'], member_data=member_data, clan_name=clan_name, ) new_setting = await request.get_json() if new_setting is None: return jsonify(code=30, message='消息体格式错误') new_nickname = new_setting.get('nickname') index = new_setting.get('index') if new_nickname is None or index is None: return jsonify(code=32, message='消息体内容错误') bm = ue.get_bm(member_data[index]['gid']) ue.mod_member(bm, user_data['uid'], new_nickname, member_data[index]['last_sl'], member_data[index]['authority_group']) return jsonify(code=0, message='success')
async def yobot_clan_statistics(group_id): bm = ue.get_bm(group_id) group = ue.get_group(bm) if group is None: return await render_template( '404.html', item='公会' ), 404 return await render_template( 'clan/statistics.html', )
async def yobot_clan(group_id): bm = ue.get_bm(group_id) group = ue.get_group(bm) if group is None: return await render_template( '404.html', item='公会' ), 404 member = ue.get_member(bm, uid=session.get('yobot_user')) if not member and member['authority_group'] >= 10: return await render_template('clan/unauthorized.html') return await render_template( 'clan/panel.html', is_member=member )
async def yobot_clan_user(group_id, uid): if 'yobot_user' not in session: return redirect(url_for('yobot_login', callback=request.path)) bm = ue.get_bm(group_id) group = ue.get_group(bm) if group is None: return await render_template('404.html', item='公会'), 404 member = ue.get_member(bm, uid=session.get('yobot_user')) if not member and member['authority_group'] >= 10: return await render_template('clan/unauthorized.html') return await render_template( 'clan/user.html', uid=uid, )
async def yobot_clan_setting(group_id): if 'yobot_user' not in session: return redirect(url_for('yobot_login', callback=request.path)) bm = ue.get_bm(group_id) group = ue.get_group(bm) if group is None: return await render_template('404.html', item='公会'), 404 member = ue.get_member(bm, uid=session.get('yobot_user')) if not member: return await render_template( 'unauthorized.html', limit='本公会成员', auth='无') if member['authority_group'] >= 100: return await render_template( 'unauthorized.html', limit='公会战管理员', auth='成员') return await render_template('clan/setting.html')
async def yobot_clan_setting_api(group_id): if 'yobot_user' not in session: return jsonify(code=10, message='Not logged in') uid = session.get('yobot_user') bm = ue.get_bm(group_id) group = ue.get_group(bm) if group is None: return jsonify(code=20, message="Group dosen't exist") member = ue.get_member(bm, uid=uid) if not member or member['authority_group'] >= 100: return jsonify(code=11, message='Insufficient authority') payload = await request.get_json() if payload is None: return jsonify(code=30, message='Invalid payload') else: payload['uid'] = uid if payload.get('csrf_token') != session['csrf_token']: return jsonify(code=15, message='Invalid csrf_token') return ue.clan_setting_api(bm, payload)