Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -20,8 +20,8 @@ if not os.path.exists(lock_file_path):
|
|
20 |
with open(lock_file_path, "w") as f:
|
21 |
f.write("Running!")
|
22 |
else:
|
23 |
-
print("Streamlit app is already running,
|
24 |
-
|
25 |
|
26 |
try:
|
27 |
os.mkdir("data")
|
@@ -53,7 +53,7 @@ launch_time = datetime.datetime.utcnow()
|
|
53 |
ph = st.empty()
|
54 |
|
55 |
async def syncMessages():
|
56 |
-
print(os.listdir("data"))
|
57 |
if os.listdir("data") == []:
|
58 |
return 0
|
59 |
with ph.container():
|
@@ -62,6 +62,7 @@ async def syncMessages():
|
|
62 |
for dir in os.listdir("data"):
|
63 |
i += 1
|
64 |
with dirs[i]:
|
|
|
65 |
if os.listdir(f"data/{dir}") == []:
|
66 |
return 0
|
67 |
files = st.tabs(os.listdir("data/" + dir))
|
@@ -73,7 +74,6 @@ async def syncMessages():
|
|
73 |
o = f.read().split("<|end_of_turn|>")
|
74 |
for item in o:
|
75 |
item = item.split(": ", 1)
|
76 |
-
print(item)
|
77 |
if len(item) < 2:
|
78 |
return 0
|
79 |
st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
|
@@ -84,15 +84,13 @@ async def on_ready():
|
|
84 |
presence.start()
|
85 |
|
86 |
|
87 |
-
@tasks.loop(seconds=
|
88 |
async def presence():
|
89 |
delta_uptime = datetime.datetime.utcnow() - launch_time
|
90 |
hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
|
91 |
minutes, seconds = divmod(remainder, 60)
|
92 |
days, hours = divmod(hours, 24)
|
93 |
print(f"Online Time: {days:02d}d | {hours:02d}h | {minutes:02d}m | {seconds:02d}s")
|
94 |
-
print("Syncing.")
|
95 |
-
await syncMessages()
|
96 |
await client.change_presence(
|
97 |
status=discord.Status.dnd,
|
98 |
activity=discord.Activity(
|
@@ -142,6 +140,7 @@ async def on_message(message):
|
|
142 |
finally:
|
143 |
with open(f"data/{guild_name}/{msgchannel_name}", "r") as f:
|
144 |
context = f.read()
|
|
|
145 |
if "Feeway" in guild_name:
|
146 |
context += f"GPT4 Correct Assistant:"
|
147 |
title = ec(context, "<title>", "</title>")[0]
|
|
|
20 |
with open(lock_file_path, "w") as f:
|
21 |
f.write("Running!")
|
22 |
else:
|
23 |
+
print("Streamlit app is already running, only streaming bot activity.")
|
24 |
+
for i in range()
|
25 |
|
26 |
try:
|
27 |
os.mkdir("data")
|
|
|
53 |
ph = st.empty()
|
54 |
|
55 |
async def syncMessages():
|
56 |
+
print(os.listdir(f"data"))
|
57 |
if os.listdir("data") == []:
|
58 |
return 0
|
59 |
with ph.container():
|
|
|
62 |
for dir in os.listdir("data"):
|
63 |
i += 1
|
64 |
with dirs[i]:
|
65 |
+
print(i, os.listdir(f"data/{dir}"))
|
66 |
if os.listdir(f"data/{dir}") == []:
|
67 |
return 0
|
68 |
files = st.tabs(os.listdir("data/" + dir))
|
|
|
74 |
o = f.read().split("<|end_of_turn|>")
|
75 |
for item in o:
|
76 |
item = item.split(": ", 1)
|
|
|
77 |
if len(item) < 2:
|
78 |
return 0
|
79 |
st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
|
|
|
84 |
presence.start()
|
85 |
|
86 |
|
87 |
+
@tasks.loop(seconds=60)
|
88 |
async def presence():
|
89 |
delta_uptime = datetime.datetime.utcnow() - launch_time
|
90 |
hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
|
91 |
minutes, seconds = divmod(remainder, 60)
|
92 |
days, hours = divmod(hours, 24)
|
93 |
print(f"Online Time: {days:02d}d | {hours:02d}h | {minutes:02d}m | {seconds:02d}s")
|
|
|
|
|
94 |
await client.change_presence(
|
95 |
status=discord.Status.dnd,
|
96 |
activity=discord.Activity(
|
|
|
140 |
finally:
|
141 |
with open(f"data/{guild_name}/{msgchannel_name}", "r") as f:
|
142 |
context = f.read()
|
143 |
+
await syncMessages()
|
144 |
if "Feeway" in guild_name:
|
145 |
context += f"GPT4 Correct Assistant:"
|
146 |
title = ec(context, "<title>", "</title>")[0]
|