auto trade and auto bandit
This commit is contained in:
@@ -195,6 +195,17 @@ def get_pending_command():
|
||||
'loot_option': farm_row['loot_option'] if farm_row else 1
|
||||
}
|
||||
|
||||
# Bot settings (bootcamp + rural trade)
|
||||
bot_row = c.execute(
|
||||
'SELECT * FROM bot_settings WHERE player_id = ?', (str(player_id),)
|
||||
).fetchone()
|
||||
bot_settings = {
|
||||
'bootcamp_enabled': bool(bot_row['bootcamp_enabled']) if bot_row else False,
|
||||
'bootcamp_use_def': bool(bot_row['bootcamp_use_def']) if bot_row else False,
|
||||
'rural_trade_enabled': bool(bot_row['rural_trade_enabled']) if bot_row else False,
|
||||
'rural_trade_ratio': bot_row['rural_trade_ratio'] if bot_row else 3,
|
||||
}
|
||||
|
||||
# Feature flags — look up this player's authorized features from their clan
|
||||
member_row = c.execute(
|
||||
'SELECT features FROM clan_members WHERE player_id = ?', (str(player_id),)
|
||||
@@ -215,6 +226,7 @@ def get_pending_command():
|
||||
'farm': farm_cmd,
|
||||
'farm_upgrade': farm_upgrade_cmd,
|
||||
'farm_settings': farm_settings,
|
||||
'bot_settings': bot_settings,
|
||||
'enabled_features': enabled_features,
|
||||
'sync_requested': sync_req
|
||||
})
|
||||
@@ -367,6 +379,46 @@ def farm_status():
|
||||
conn.close()
|
||||
return jsonify(json.loads(row['value']) if row else {'warehouse_full': False})
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# POST /api/bot-logs
|
||||
# TM bot reports log entries for bootcamp / rural_trade loops.
|
||||
# ------------------------------------------------------------------
|
||||
@api.route('/api/bot-logs', methods=['POST'])
|
||||
def api_bot_logs():
|
||||
clan = _get_clan_from_request()
|
||||
if not clan:
|
||||
return make_response('Unauthorized', 403)
|
||||
|
||||
data = request.get_json(silent=True) or {}
|
||||
player_id = str(data.get('player_id', ''))
|
||||
feature = data.get('feature', '')
|
||||
message = data.get('message', '')
|
||||
|
||||
if not player_id or not feature or not message:
|
||||
return jsonify({'error': 'missing fields'}), 400
|
||||
|
||||
conn = get_db()
|
||||
conn.execute(
|
||||
'INSERT INTO bot_logs (player_id, feature, message) VALUES (?, ?, ?)',
|
||||
(player_id, feature, message)
|
||||
)
|
||||
# Keep only latest 50 per player/feature
|
||||
conn.execute('''
|
||||
DELETE FROM bot_logs
|
||||
WHERE player_id = ? AND feature = ?
|
||||
AND id NOT IN (
|
||||
SELECT id FROM bot_logs
|
||||
WHERE player_id = ? AND feature = ?
|
||||
ORDER BY id DESC LIMIT 50
|
||||
)
|
||||
''', (player_id, feature, player_id, feature))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return jsonify({'ok': True})
|
||||
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# GET /api/bot
|
||||
# Serves the modular bot code concatenated into a single response
|
||||
|
||||
Reference in New Issue
Block a user