Araeynn commited on
Commit
03b0f62
1 Parent(s): 2cef94c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -48
app.py CHANGED
@@ -41,42 +41,15 @@ async def syncMessages():
41
  item = item.split(": ", 1)
42
  st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
43
 
44
- def syncViewMessages():
45
- print(os.listdir(f"data"))
46
- if os.listdir("data") == []:
47
- return 0
48
- with ph.container():
49
- dirs = st.tabs(os.listdir("data"))
50
- i = -1
51
- for dir in os.listdir("data"):
52
- i += 1
53
- with dirs[i]:
54
- print(i, os.listdir(f"data/{dir}"))
55
- if os.listdir(f"data/{dir}") == []:
56
- return 0
57
- files = st.tabs(os.listdir("data/" + dir))
58
- k = -1
59
- for file in os.listdir("data/" + dir):
60
- k += 1
61
- with files[k]:
62
- with open(f"data/{dir}/{file}", "r") as f:
63
- o = f.read().split("<|end_of_turn|>")
64
- print(o)
65
- for item in o:
66
- if item == "":
67
- continue
68
- item = item.split(": ", 1)
69
- st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
70
-
71
  lock_file_path = "test.txt"
72
 
73
  if not os.path.exists(lock_file_path):
74
  with open(lock_file_path, "w") as f:
75
  f.write("Running!")
 
76
  else:
77
- print("Streamlit app is already running, only streaming bot activity.")
78
- while True:
79
- syncViewMessages()
80
 
81
  try:
82
  os.mkdir("data")
@@ -109,33 +82,39 @@ ph = st.empty()
109
 
110
  @client.event
111
  async def on_ready():
112
- print(f"Logged in as {client.user}")
113
- presence.start()
 
 
 
114
 
115
 
116
  @tasks.loop(seconds=60)
117
  async def presence():
118
- delta_uptime = datetime.datetime.utcnow() - launch_time
119
- hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
120
- minutes, seconds = divmod(remainder, 60)
121
- days, hours = divmod(hours, 24)
122
- print(f"Online Time: {days:02d}d | {hours:02d}h | {minutes:02d}m | {seconds:02d}s")
123
- await client.change_presence(
124
- status=discord.Status.dnd,
125
- activity=discord.Activity(
126
- type=discord.ActivityType.playing,
127
- large_image="https://i.imgur.com/Kk2BvJg.jpg",
128
- large_text="This is Game Icon",
129
- name="Escaping the IRS.",
130
- details="",
131
- state=f"Running for {days:02d}d | {hours:02d}h | {minutes:02d}m",
132
- ),
133
- )
 
134
 
135
 
136
  @client.event
137
  async def on_message(message):
138
  await syncMessages()
 
 
139
  for user in message.mentions:
140
  message.content = message.content.replace(f"<@{user.id}>",
141
  f"@{str(user)}")
 
41
  item = item.split(": ", 1)
42
  st.markdown(f":blue[{item[0].split('GPT4 Correct ')[1]}]: {item[1]}")
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  lock_file_path = "test.txt"
45
 
46
  if not os.path.exists(lock_file_path):
47
  with open(lock_file_path, "w") as f:
48
  f.write("Running!")
49
+ clone = False
50
  else:
51
+ print("Streamlit app is already running, only streaming activity.")
52
+ clone = True
 
53
 
54
  try:
55
  os.mkdir("data")
 
82
 
83
  @client.event
84
  async def on_ready():
85
+ if clone:
86
+ print(f"Clone started.")
87
+ else:
88
+ print(f"Logged in as {client.user}")
89
+ presence.start()
90
 
91
 
92
  @tasks.loop(seconds=60)
93
  async def presence():
94
+ if not clone:
95
+ delta_uptime = datetime.datetime.utcnow() - launch_time
96
+ hours, remainder = divmod(int(delta_uptime.total_seconds()), 3600)
97
+ minutes, seconds = divmod(remainder, 60)
98
+ days, hours = divmod(hours, 24)
99
+ print(f"Online Time: {days:02d}d | {hours:02d}h | {minutes:02d}m | {seconds:02d}s")
100
+ await client.change_presence(
101
+ status=discord.Status.dnd,
102
+ activity=discord.Activity(
103
+ type=discord.ActivityType.playing,
104
+ large_image="https://i.imgur.com/Kk2BvJg.jpg",
105
+ large_text="This is Game Icon",
106
+ name="Escaping the IRS.",
107
+ details="",
108
+ state=f"Running for {days:02d}d | {hours:02d}h | {minutes:02d}m",
109
+ ),
110
+ )
111
 
112
 
113
  @client.event
114
  async def on_message(message):
115
  await syncMessages()
116
+ if clone:
117
+ return 0
118
  for user in message.mentions:
119
  message.content = message.content.replace(f"<@{user.id}>",
120
  f"@{str(user)}")