Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -30,6 +30,7 @@ with open(file_path, 'w') as json_file:
|
|
30 |
json.dump(service_account, json_file)
|
31 |
gspread_bot = gspread.service_account(filename='service_account.json')
|
32 |
worksheet = gspread_bot.open("levelbot").sheet1
|
|
|
33 |
""""""
|
34 |
bot_ids = [1136614989411655780, 1166392942387265536, 1158038249835610123, 1130774761031610388, 1155489509518098565, 1155169841276260546, 1152238037355474964, 1154395078735953930]
|
35 |
""""""
|
@@ -58,27 +59,27 @@ def calculate_xp(level):
|
|
58 |
@bot.command(name='add_exp_hub')
|
59 |
async def add_exp_hub(ctx, discord_user_id):
|
60 |
try:
|
61 |
-
cell =
|
62 |
if cell.col == 5:
|
63 |
# find hub_user_name
|
64 |
-
hf_user_name =
|
65 |
if hf_user_name:
|
66 |
# check likes
|
67 |
likes = list_liked_repos(f"{hf_user_name}")
|
68 |
hf_likes_new = likes.total
|
69 |
-
hf_likes_old =
|
70 |
if hf_likes_old:
|
71 |
hf_likes_old = int(hf_likes_old)
|
72 |
difference = hf_likes_new - hf_likes_old
|
73 |
if difference > 0:
|
74 |
-
|
75 |
"""
|
76 |
for i in range(difference):
|
77 |
await add_exp(discord_user_id)
|
78 |
"""
|
79 |
|
80 |
else:
|
81 |
-
|
82 |
|
83 |
except Exception as e:
|
84 |
print(f"add_exp_hub Error: {e}")
|
|
|
30 |
json.dump(service_account, json_file)
|
31 |
gspread_bot = gspread.service_account(filename='service_account.json')
|
32 |
worksheet = gspread_bot.open("levelbot").sheet1
|
33 |
+
worksheet2 = gspread_bot.open("hf_discord_verified_users_test").sheet1
|
34 |
""""""
|
35 |
bot_ids = [1136614989411655780, 1166392942387265536, 1158038249835610123, 1130774761031610388, 1155489509518098565, 1155169841276260546, 1152238037355474964, 1154395078735953930]
|
36 |
""""""
|
|
|
59 |
@bot.command(name='add_exp_hub')
|
60 |
async def add_exp_hub(ctx, discord_user_id):
|
61 |
try:
|
62 |
+
cell = worksheet2.find(str(discord_user_id))
|
63 |
if cell.col == 5:
|
64 |
# find hub_user_name
|
65 |
+
hf_user_name = worksheet2.cell(cell.row, cell.col-2).value
|
66 |
if hf_user_name:
|
67 |
# check likes
|
68 |
likes = list_liked_repos(f"{hf_user_name}")
|
69 |
hf_likes_new = likes.total
|
70 |
+
hf_likes_old = worksheet2.cell(cell.row, cell.col+2).value
|
71 |
if hf_likes_old:
|
72 |
hf_likes_old = int(hf_likes_old)
|
73 |
difference = hf_likes_new - hf_likes_old
|
74 |
if difference > 0:
|
75 |
+
worksheet2.update(f'G{cell.row}', f'{hf_likes_new}')
|
76 |
"""
|
77 |
for i in range(difference):
|
78 |
await add_exp(discord_user_id)
|
79 |
"""
|
80 |
|
81 |
else:
|
82 |
+
worksheet2.update(f'G{cell.row}', f'{hf_likes_new}')
|
83 |
|
84 |
except Exception as e:
|
85 |
print(f"add_exp_hub Error: {e}")
|