fix ?
This commit is contained in:
@@ -84,9 +84,12 @@ def player_farm(player_id, world_id):
|
||||
@dashboard.route('/dashboard/farm-settings', methods=['GET'])
|
||||
def get_farm_settings():
|
||||
player_id = request.args.get('player_id')
|
||||
world_id = request.args.get('world_id', '')
|
||||
player_key = f"{player_id}_{world_id}" if world_id else player_id
|
||||
|
||||
conn = get_db()
|
||||
row = conn.execute(
|
||||
'SELECT enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_id,)
|
||||
'SELECT enabled, loot_option FROM farm_settings WHERE player_id = ?', (player_key,)
|
||||
).fetchone()
|
||||
conn.close()
|
||||
if row:
|
||||
@@ -99,6 +102,9 @@ def set_farm_settings():
|
||||
if not data or 'player_id' not in data:
|
||||
return jsonify({'error': 'missing player_id'}), 400
|
||||
player_id = data['player_id']
|
||||
world_id = data.get('world_id', '')
|
||||
player_key = f"{player_id}_{world_id}" if world_id else player_id
|
||||
|
||||
enabled = 1 if data.get('enabled') else 0
|
||||
loot_option = int(data.get('loot_option', 1))
|
||||
conn = get_db()
|
||||
@@ -109,7 +115,7 @@ def set_farm_settings():
|
||||
enabled = excluded.enabled,
|
||||
loot_option = excluded.loot_option,
|
||||
updated_at = excluded.updated_at
|
||||
''', (player_id, enabled, loot_option, datetime.utcnow().isoformat()))
|
||||
''', (player_key, enabled, loot_option, datetime.utcnow().isoformat()))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return jsonify({'ok': True})
|
||||
@@ -521,15 +527,18 @@ def fail_stale_commands():
|
||||
@dashboard.route('/dashboard/bot-settings', methods=['GET', 'POST'])
|
||||
def bot_settings():
|
||||
player_id = request.args.get('player_id') or (request.json or {}).get('player_id')
|
||||
world_id = request.args.get('world_id') or (request.json or {}).get('world_id', '')
|
||||
if not player_id:
|
||||
return jsonify({'error': 'missing player_id'}), 400
|
||||
|
||||
player_key = f"{player_id}_{world_id}" if world_id else player_id
|
||||
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
|
||||
if request.method == 'GET':
|
||||
row = c.execute(
|
||||
'SELECT * FROM bot_settings WHERE player_id = ?', (player_id,)
|
||||
'SELECT * FROM bot_settings WHERE player_id = ?', (player_key,)
|
||||
).fetchone()
|
||||
conn.close()
|
||||
if row:
|
||||
@@ -555,7 +564,7 @@ def bot_settings():
|
||||
rural_trade_ratio = excluded.rural_trade_ratio,
|
||||
updated_at = excluded.updated_at
|
||||
''', (
|
||||
player_id,
|
||||
player_key,
|
||||
int(bool(data.get('bootcamp_enabled', 0))),
|
||||
int(bool(data.get('bootcamp_use_def', 0))),
|
||||
int(bool(data.get('rural_trade_enabled', 0))),
|
||||
@@ -574,8 +583,11 @@ def bot_settings():
|
||||
@dashboard.route('/dashboard/bot-logs', methods=['GET', 'POST'])
|
||||
def bot_logs():
|
||||
player_id = request.args.get('player_id') or (request.json or {}).get('player_id')
|
||||
world_id = request.args.get('world_id') or (request.json or {}).get('world_id', '')
|
||||
if not player_id:
|
||||
return jsonify({'error': 'missing player_id'}), 400
|
||||
|
||||
player_key = f"{player_id}_{world_id}" if world_id else player_id
|
||||
|
||||
conn = get_db()
|
||||
c = conn.cursor()
|
||||
@@ -583,7 +595,7 @@ def bot_logs():
|
||||
if request.method == 'GET':
|
||||
feature = request.args.get('feature', '')
|
||||
query = 'SELECT * FROM bot_logs WHERE player_id = ?'
|
||||
params = [player_id]
|
||||
params = [player_key]
|
||||
if feature:
|
||||
query += ' AND feature = ?'
|
||||
params.append(feature)
|
||||
@@ -598,7 +610,7 @@ def bot_logs():
|
||||
message = data.get('message', '')
|
||||
c.execute(
|
||||
'INSERT INTO bot_logs (player_id, feature, message) VALUES (?, ?, ?)',
|
||||
(player_id, feature, message)
|
||||
(player_key, feature, message)
|
||||
)
|
||||
# Prune: keep only the latest 50 per player/feature
|
||||
c.execute('''
|
||||
@@ -609,7 +621,7 @@ def bot_logs():
|
||||
WHERE player_id = ? AND feature = ?
|
||||
ORDER BY id DESC LIMIT 50
|
||||
)
|
||||
''', (player_id, feature, player_id, feature))
|
||||
''', (player_key, feature, player_key, feature))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return jsonify({'ok': True})
|
||||
@@ -623,9 +635,12 @@ def bot_logs():
|
||||
@dashboard.route('/dashboard/bootcamp-attack-now', methods=['POST'])
|
||||
def bootcamp_attack_now():
|
||||
player_id = (request.json or {}).get('player_id')
|
||||
world_id = (request.json or {}).get('world_id', '')
|
||||
if not player_id:
|
||||
return jsonify({'error': 'missing player_id'}), 400
|
||||
key = f'bootcamp_attack_now_{player_id}'
|
||||
|
||||
player_key = f"{player_id}_{world_id}" if world_id else player_id
|
||||
key = f'bootcamp_attack_now_{player_key}'
|
||||
conn = get_db()
|
||||
conn.execute('''
|
||||
INSERT INTO kv_store (key, value, updated_at) VALUES (?, '1', ?)
|
||||
|
||||
Reference in New Issue
Block a user