Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
max_instances = 2
Browse files
app.py
CHANGED
|
@@ -96,6 +96,7 @@ def update_google_sheet():
|
|
| 96 |
"""save data from HF Space -> google sheets (makes 2 API calls)"""
|
| 97 |
try:
|
| 98 |
print("Updating google sheets...")
|
|
|
|
| 99 |
name = "levelbot"
|
| 100 |
#worksheet = gspread_bot.open(name).sheet1
|
| 101 |
global_df['discord_user_id'] = global_df['discord_user_id'].astype(str)
|
|
@@ -114,9 +115,9 @@ def update_google_sheet():
|
|
| 114 |
except Exception as e:
|
| 115 |
print(f"update_google_sheet Error: {e}")
|
| 116 |
|
| 117 |
-
executor = ThreadPoolExecutor(max_workers=
|
| 118 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
| 119 |
-
scheduler.add_job(update_google_sheet, trigger='interval', minutes=
|
| 120 |
scheduler.start()
|
| 121 |
|
| 122 |
|
|
@@ -293,7 +294,13 @@ async def add_exp(member_id):
|
|
| 293 |
# temporary fix: remove ~100 exp when not verified, send embed on "levelup" prompting to verify
|
| 294 |
# if level 3 -> then send embed, remove some exp
|
| 295 |
if current_level >= 3: # could change to 4 maybe
|
| 296 |
-
if verified_role not in member.roles:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 297 |
if new_xp % 50 == 0: # staggers messages so we don't send one every time exp is earned
|
| 298 |
# claim exp (-30 for level 3, but +100 as bonus exp. This scales infinitely until the member verifies,
|
| 299 |
# so they can continue earning exp, it just won't translate to levels and the leaderboard.
|
|
@@ -316,7 +323,7 @@ async def add_exp(member_id):
|
|
| 316 |
embed.set_image(url='https://cdn.discordapp.com/attachments/1150399343912833024/1205537451242688573/download_1.png?ex=65d8bb3e&is=65c6463e&hm=042fe7dd3521887db0bd48eeb846de1cc7c75194f9e95215c23512ff61ea3475&')
|
| 317 |
|
| 318 |
lunar = bot.get_user(811235357663297546)
|
| 319 |
-
await
|
| 320 |
print(f"Sent verification cap embed to {member}")
|
| 321 |
return
|
| 322 |
|
|
@@ -355,7 +362,7 @@ async def add_exp(member_id):
|
|
| 355 |
embed.add_field(name="Verify Here:", value=verification_link, inline=True)
|
| 356 |
|
| 357 |
lunar = bot.get_user(811235357663297546)
|
| 358 |
-
await
|
| 359 |
print(f"Sent levelup embed to {member}")
|
| 360 |
#You can verify your account to earn 100 points! To verify, do A.
|
| 361 |
|
|
|
|
| 96 |
"""save data from HF Space -> google sheets (makes 2 API calls)"""
|
| 97 |
try:
|
| 98 |
print("Updating google sheets...")
|
| 99 |
+
print(f"------------------------------------------------------------------------")
|
| 100 |
name = "levelbot"
|
| 101 |
#worksheet = gspread_bot.open(name).sheet1
|
| 102 |
global_df['discord_user_id'] = global_df['discord_user_id'].astype(str)
|
|
|
|
| 115 |
except Exception as e:
|
| 116 |
print(f"update_google_sheet Error: {e}")
|
| 117 |
|
| 118 |
+
executor = ThreadPoolExecutor(max_workers=2)
|
| 119 |
scheduler = BackgroundScheduler(executors={'default': executor})
|
| 120 |
+
scheduler.add_job(update_google_sheet, trigger='interval', minutes=1, max_instances=2)
|
| 121 |
scheduler.start()
|
| 122 |
|
| 123 |
|
|
|
|
| 294 |
# temporary fix: remove ~100 exp when not verified, send embed on "levelup" prompting to verify
|
| 295 |
# if level 3 -> then send embed, remove some exp
|
| 296 |
if current_level >= 3: # could change to 4 maybe
|
| 297 |
+
if verified_role not in member.roles:
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
# XP has L; remove, calculate
|
| 301 |
+
new_xp = new_xp[1:-1]
|
| 302 |
+
new_xp = int(new_xp)
|
| 303 |
+
|
| 304 |
if new_xp % 50 == 0: # staggers messages so we don't send one every time exp is earned
|
| 305 |
# claim exp (-30 for level 3, but +100 as bonus exp. This scales infinitely until the member verifies,
|
| 306 |
# so they can continue earning exp, it just won't translate to levels and the leaderboard.
|
|
|
|
| 323 |
embed.set_image(url='https://cdn.discordapp.com/attachments/1150399343912833024/1205537451242688573/download_1.png?ex=65d8bb3e&is=65c6463e&hm=042fe7dd3521887db0bd48eeb846de1cc7c75194f9e95215c23512ff61ea3475&')
|
| 324 |
|
| 325 |
lunar = bot.get_user(811235357663297546)
|
| 326 |
+
await member.send(embed=embed)
|
| 327 |
print(f"Sent verification cap embed to {member}")
|
| 328 |
return
|
| 329 |
|
|
|
|
| 362 |
embed.add_field(name="Verify Here:", value=verification_link, inline=True)
|
| 363 |
|
| 364 |
lunar = bot.get_user(811235357663297546)
|
| 365 |
+
await member.send(embed=embed)
|
| 366 |
print(f"Sent levelup embed to {member}")
|
| 367 |
#You can verify your account to earn 100 points! To verify, do A.
|
| 368 |
|