Skip to content

Commit

Permalink
Code restructuring and IMPORTANT BUG FIX!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
PlaceReporter99 committed Apr 28, 2024
1 parent f61e31e commit 8dff46c
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions utilitybot.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,6 @@ def page():

main_ = __name__ == "__main__"

if main_:
bot = sechat.Bot()
bot.login(os.environ("BOT_EMAIL"), os.environ("BOT_PASSWORD"))
r = bot.joinRoom(1)
#t = bot.joinRoom(147676)
#priv = bot.joinRoom(147571)
#sb2 = bot.joinRoom(147516)
baso = bot.joinRoom(146039)
#den = bot.joinRoom(148152)
#t4d = bot.joinRoom(148981)
#pic = bot.joinRoom(152450)

"""def ai(text):
global c, h, last_msg # skipcq: PYL-W0602
c.add_user_input(html.unescape(text))
response = h(c).generated_responses[-1]
if response == last_msg:
c = Conversation()
c.add_user_input(html.unescape(text))
last_msg = h(c).generated_responses[-1]
else:
last_msg = response
return last_msg"""


def onn(room):
room.on(Events.MESSAGE, roomer(room))
Expand Down Expand Up @@ -385,8 +361,13 @@ def msg(event):


if main_:
for room in [r, baso]:
onn(room)
bot = sechat.Bot()
bot.login(os.environ["BOT_EMAIL"], os.environ["BOT_PASSWORD"])
def repeat():
[r, baso] = [bot.joinRoom(1), bot.joinRoom(146039)]
for room in [r, baso]:
onn(room)
repeat()
app.run(host='0.0.0.0', port=5000)
try:
counter = 0
Expand All @@ -396,6 +377,8 @@ def msg(event):
# st.write(f"Bot is running. Seconds since start: {counter}")
time.sleep(1)
counter += 1
if counter % 3600 == 0:
repeat()
finally:
r.send("Bot has stopped for updates.")
bot.leaveAllRooms()

0 comments on commit 8dff46c

Please sign in to comment.