From e88da07294ecfbf08cfdb464df1ff5bb10086ef7 Mon Sep 17 00:00:00 2001 From: Little Monkey <106759534+PlaceReporter99@users.noreply.github.com> Date: Sat, 31 Aug 2024 15:05:36 +0100 Subject: [PATCH] big code refactor Signed-off-by: Little Monkey <106759534+PlaceReporter99@users.noreply.github.com> --- main.py | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/main.py b/main.py index 9835ab7..756d6b8 100644 --- a/main.py +++ b/main.py @@ -330,30 +330,18 @@ def msg(event): if main_: - [r, baso, ubot] = [1, 1, 1] # Temp, will be replaced once repeat() is run. I think. - def mainf(): - bot = sechat.Bot() - bot.login(os.environ["BOT_EMAIL"], os.environ["BOT_PASSWORD"]) - def repeat(): - [r, baso, ubot] = map(bot.joinRoom, [1, 146039, 154629]) - for room in [r, baso, ubot]: - onn(room) - ubot.send(f"Wake up, it's antifreeze time!") - repeat() - try: - counter = 0 - print("Startup Successful.") - while True: - print(f"Bot is running. Seconds since start: {counter}") - # st.write(f"Bot is running. Seconds since start: {counter}") - time.sleep(1) - counter += 1 - if counter % 3600 == 0: - ubot.send(f"Wake up, it's antifreeze time!") - finally: - #r.send("Bot has stopped for updates.") - bot.leaveAllRooms() - mainf() + [r, baso, ubot] = map(bot.joinRoom, [1, 146039, 154629]) + bot = sechat.Bot() + bot.login(os.environ["BOT_EMAIL"], os.environ["BOT_PASSWORD"]) + + for room in [r, baso, ubot]: + onn(room) + + try: + while True: + pass + finally: + bot.leaveAllRooms() + app.run(host='0.0.0.0', port=5000) - mainf()