Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
xp -> exp
Browse files
app.py
CHANGED
@@ -263,29 +263,29 @@ async def add_exp(member_id):
|
|
263 |
new_xp = int(old_xp) + XP_PER_MESSAGE
|
264 |
|
265 |
# ----------------------------------------------------
|
266 |
-
|
267 |
hub_xp = global_df.loc[index, 'hub_exp']
|
268 |
|
269 |
-
|
270 |
hub_xp = str(hub_xp)
|
271 |
|
272 |
-
if
|
273 |
-
|
274 |
if hub_xp.startswith("L") and hub_xp.endswith("L"):
|
275 |
hub_xp = hub_xp[1:-1]
|
276 |
|
277 |
-
old_total_xp = int(
|
278 |
|
279 |
# check if hub exp not empty
|
280 |
if hub_xp.strip():
|
281 |
-
|
282 |
else:
|
283 |
-
|
284 |
|
285 |
# ----------------------------------------------------
|
286 |
|
287 |
# total v
|
288 |
-
current_level = calculate_level(
|
289 |
|
290 |
# convert back to string + google sheet proofing
|
291 |
new_xp = str(new_xp)
|
@@ -294,13 +294,13 @@ async def add_exp(member_id):
|
|
294 |
global_df.loc[index, 'discord_exp'] = new_xp # do not change column name
|
295 |
|
296 |
# after
|
297 |
-
if not
|
298 |
-
|
299 |
|
300 |
# add back to dataframe in memory after checking redundantly;
|
301 |
-
if
|
302 |
print("test5")
|
303 |
-
global_df.loc[index, 'total_exp'] =
|
304 |
print(f"Record for {member} updated from {old_total_xp} to {global_df.loc[index, 'total_exp']} (+{XP_PER_MESSAGE}) ")
|
305 |
|
306 |
# level up
|
@@ -320,12 +320,12 @@ async def add_exp(member_id):
|
|
320 |
# do calculations
|
321 |
copy_df = global_df.copy()
|
322 |
copy_df['discord_user_id'] = copy_df['discord_user_id'].str.strip('L').astype(str)
|
323 |
-
copy_df['
|
324 |
row = copy_df[copy_df['discord_user_id'] == str(member_id)]
|
325 |
print(f"Row found for {member_id}!")
|
326 |
-
target_exp = row['
|
327 |
-
rank = (copy_df['
|
328 |
-
print(f"The rank for discord_id {member_id} based on
|
329 |
except Exception as e:
|
330 |
print(f"Discord ID {member_id} not found in the DataFrame.")
|
331 |
rank = "π€"
|
@@ -337,14 +337,14 @@ async def add_exp(member_id):
|
|
337 |
|
338 |
|
339 |
# L12345L -> `12345` -> 12345
|
340 |
-
|
341 |
-
|
342 |
|
343 |
-
if
|
344 |
# claim exp (-30 for level 3, but +100 as bonus exp. This scales infinitely until the member verifies,
|
345 |
# so they can continue earning exp, it just won't translate to levels and the leaderboard.
|
346 |
# This way they can claim at any time and get a big boost in levels!
|
347 |
-
claim_exp =
|
348 |
|
349 |
# send embed
|
350 |
embed = Embed(color=Color.red())
|
@@ -484,11 +484,11 @@ async def remove_huggingfolks():
|
|
484 |
|
485 |
# drop first column (discord id -> this is so we can display the important stuff in the leaderboard)
|
486 |
community_global_df.drop(community_global_df.columns[0], axis=1, inplace=True)
|
487 |
-
community_global_df['
|
488 |
-
community_global_df['
|
489 |
-
community_global_df = community_global_df.nlargest(len(community_global_df), '
|
490 |
|
491 |
-
top_30_exp = community_global_df.nlargest(30, '
|
492 |
|
493 |
top_30_exp['D'] = ['π₯','π₯','π₯','','','','','','','','','','','','','','','','','','','','','','','','','','','']
|
494 |
top_30_rows = top_30_exp.values.tolist()
|
|
|
263 |
new_xp = int(old_xp) + XP_PER_MESSAGE
|
264 |
|
265 |
# ----------------------------------------------------
|
266 |
+
total_exp = global_df.loc[index, 'total_exp']
|
267 |
hub_xp = global_df.loc[index, 'hub_exp']
|
268 |
|
269 |
+
total_exp = str(total_exp)
|
270 |
hub_xp = str(hub_xp)
|
271 |
|
272 |
+
if total_exp.startswith("L") and total_exp.endswith("L"):
|
273 |
+
total_exp = total_exp[1:-1]
|
274 |
if hub_xp.startswith("L") and hub_xp.endswith("L"):
|
275 |
hub_xp = hub_xp[1:-1]
|
276 |
|
277 |
+
old_total_xp = int(total_exp)
|
278 |
|
279 |
# check if hub exp not empty
|
280 |
if hub_xp.strip():
|
281 |
+
total_exp = int(new_xp) + int(hub_xp)
|
282 |
else:
|
283 |
+
total_exp = int(new_xp)
|
284 |
|
285 |
# ----------------------------------------------------
|
286 |
|
287 |
# total v
|
288 |
+
current_level = calculate_level(total_exp)
|
289 |
|
290 |
# convert back to string + google sheet proofing
|
291 |
new_xp = str(new_xp)
|
|
|
294 |
global_df.loc[index, 'discord_exp'] = new_xp # do not change column name
|
295 |
|
296 |
# after
|
297 |
+
if not total_exp.startswith("L") and not total_exp.endswith("L"):
|
298 |
+
total_exp = f"L" + str(total_exp) + f"L"
|
299 |
|
300 |
# add back to dataframe in memory after checking redundantly;
|
301 |
+
if total_exp.startswith("L") and total_exp.endswith("L"):
|
302 |
print("test5")
|
303 |
+
global_df.loc[index, 'total_exp'] = total_exp # do not change column name
|
304 |
print(f"Record for {member} updated from {old_total_xp} to {global_df.loc[index, 'total_exp']} (+{XP_PER_MESSAGE}) ")
|
305 |
|
306 |
# level up
|
|
|
320 |
# do calculations
|
321 |
copy_df = global_df.copy()
|
322 |
copy_df['discord_user_id'] = copy_df['discord_user_id'].str.strip('L').astype(str)
|
323 |
+
copy_df['total_exp'] = copy_df['total_exp'].str.strip('L').astype(int)
|
324 |
row = copy_df[copy_df['discord_user_id'] == str(member_id)]
|
325 |
print(f"Row found for {member_id}!")
|
326 |
+
target_exp = row['total_exp'].values[0]
|
327 |
+
rank = (copy_df['total_exp'] > target_exp).sum() + 1
|
328 |
+
print(f"The rank for discord_id {member_id} based on total_exp is: {rank}")
|
329 |
except Exception as e:
|
330 |
print(f"Discord ID {member_id} not found in the DataFrame.")
|
331 |
rank = "π€"
|
|
|
337 |
|
338 |
|
339 |
# L12345L -> `12345` -> 12345
|
340 |
+
total_exp = total_exp[1:-1]
|
341 |
+
total_exp = int(total_exp)
|
342 |
|
343 |
+
if total_exp % 10 == 0: # staggers messages so we don't send one every time exp is earned
|
344 |
# claim exp (-30 for level 3, but +100 as bonus exp. This scales infinitely until the member verifies,
|
345 |
# so they can continue earning exp, it just won't translate to levels and the leaderboard.
|
346 |
# This way they can claim at any time and get a big boost in levels!
|
347 |
+
claim_exp = total_exp + 70
|
348 |
|
349 |
# send embed
|
350 |
embed = Embed(color=Color.red())
|
|
|
484 |
|
485 |
# drop first column (discord id -> this is so we can display the important stuff in the leaderboard)
|
486 |
community_global_df.drop(community_global_df.columns[0], axis=1, inplace=True)
|
487 |
+
community_global_df['total_exp'] = community_global_df['total_exp'].str.strip('L').astype(int)
|
488 |
+
community_global_df['total_exp'] = pd.to_numeric(community_global_df['total_exp'])
|
489 |
+
community_global_df = community_global_df.nlargest(len(community_global_df), 'total_exp')
|
490 |
|
491 |
+
top_30_exp = community_global_df.nlargest(30, 'total_exp')
|
492 |
|
493 |
top_30_exp['D'] = ['π₯','π₯','π₯','','','','','','','','','','','','','','','','','','','','','','','','','','','']
|
494 |
top_30_rows = top_30_exp.values.tolist()
|