mirror of
https://github.com/zoffline/zwift-offline.git
synced 2026-08-03 01:15:46 -07:00
Merge pull request #22 from Argon2000/master
Add button / api to reload bots
This commit is contained in:
+2
-1
@@ -3,4 +3,5 @@ storage/*
|
||||
!storage/force_dir_in_git.txt
|
||||
example-requests/*
|
||||
zoffline.log
|
||||
migrate_auth.sql
|
||||
migrate_auth.sql
|
||||
bots
|
||||
@@ -20,6 +20,9 @@
|
||||
{% elif is_admin %}
|
||||
<a href="/cancelrestart" class="btn btn-sm btn-danger">Cancel restart</a>
|
||||
{% endif %}
|
||||
{% if is_admin %}
|
||||
<a href="/reloadbots" class="btn btn-sm btn-warning">Reload bots</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -402,7 +402,12 @@ def load_bots():
|
||||
bot.position = 0
|
||||
|
||||
def play_bots():
|
||||
global global_bots
|
||||
while True:
|
||||
if zwift_offline.reload_pacer_bots:
|
||||
zwift_offline.reload_pacer_bots = False
|
||||
global_bots.clear()
|
||||
load_bots()
|
||||
for bot_id in global_bots.keys():
|
||||
bot = global_bots[bot_id]
|
||||
if bot.position < len(bot.route.states) - 1: bot.position += 1
|
||||
|
||||
@@ -99,6 +99,7 @@ app.config['MAX_CONTENT_LENGTH'] = 1024 * 1024
|
||||
db = SQLAlchemy(app)
|
||||
online = {}
|
||||
global_pace_partners = {}
|
||||
global_bots = {}
|
||||
ghosts_enabled = {}
|
||||
player_update_queue = {}
|
||||
player_ids = {}
|
||||
@@ -106,6 +107,7 @@ player_partial_profiles = {}
|
||||
save_ghost = None
|
||||
restarting = False
|
||||
restarting_in_minutes = 0
|
||||
reload_pacer_bots = False
|
||||
|
||||
class User(UserMixin, db.Model):
|
||||
player_id = db.Column(db.Integer, primary_key=True)
|
||||
@@ -384,6 +386,14 @@ def cancel_restart_server():
|
||||
send_message_to_all_online('Restart of the server has been cancelled. Ride on!')
|
||||
return redirect('/user/%s/' % current_user.username)
|
||||
|
||||
@app.route("/reloadbots")
|
||||
@login_required
|
||||
def reload_bots():
|
||||
global reload_pacer_bots
|
||||
if bool(current_user.is_admin):
|
||||
reload_pacer_bots = True
|
||||
return redirect('/user/%s/' % current_user.username)
|
||||
|
||||
@app.route("/upload/<username>/", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def upload(username):
|
||||
|
||||
Reference in New Issue
Block a user