Last update of the day

Signed-off-by: Moonlit Jolteon <moonlit@munebase.dev>
This commit is contained in:
2024-12-05 15:02:24 -05:00
parent 29573d5d24
commit 58f9fb7603
9 changed files with 93 additions and 56 deletions

28
main.py
View File

@ -12,25 +12,37 @@ def root():
@app.route('/tasks')
def tasks():
return "<br>".join([task.name for task in manager.queue.queue])
return "<br>".join([task.name for task in manager.tasks.queue])
num = 0
@app.route('/add_task')
def add_tasks():
def add_task():
global num
manager.queue(Task(f"Task {num}", demo_task, num))
manager.queue(Task(f"Demo Task {num}", demo_task, num))
num += 1
return "Done"
@app.route('/add_many_tasks')
def add_many_tasks():
global num
i = 0
while i < 20:
manager.queue(Task(f"Demo Task {num}", demo_task, num))
i += 1
num += 1
return "Done"
def run():
for i in range(1):
MCBot(f"bot{i}", manager, is_king = (i == 0))
MCBot(f"HiveMineAgent", manager, is_king = True)
print("You can access the task list at 127.0.0.1:5000/tasks") # TODO: figure out how to read url/port dynamically
print("You can add a single demo task at 127.0.0.1:5000/add_task")
print("You can add 20 demo tasks at 127.0.0.1:5000/add_many_tasks")
app.run()
def demo_task(num):
sleep(1)
print(f"Task {num}")
def demo_task(bot_obj, num):
sleep(0.2)
bot_obj.bot.chat(f"I have completed the demo task! ({num})")
if __name__ == '__main__':
run()