Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,8 @@ from discord.ext import commands
|
|
| 5 |
import json
|
| 6 |
import datetime
|
| 7 |
import requests
|
|
|
|
|
|
|
| 8 |
|
| 9 |
import gradio_client
|
| 10 |
import gradio as gr
|
|
@@ -20,6 +22,13 @@ XP_PER_MESSAGE = 10 # 100k messages = 1M exp = lvl 100
|
|
| 20 |
data_file_path = '/data/xp_data.json'
|
| 21 |
xp_data = {}
|
| 22 |
""""""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
API_URL = "https://api-inference.huggingface.co/models/mariagrandury/roberta-base-finetuned-sms-spam-detection"
|
| 25 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
|
@@ -245,14 +254,21 @@ async def restore_exp(ctx):
|
|
| 245 |
# find all members with lvl13 role
|
| 246 |
members_with_role = [member.id for member in ctx.guild.members if lvl13 in member.roles]
|
| 247 |
# extract user_id + xp based on level
|
| 248 |
-
for
|
| 249 |
-
print(member2)
|
| 250 |
xp = calculate_xp(13)
|
| 251 |
level = calculate_level(xp+1)
|
| 252 |
-
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 254 |
|
| 255 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 256 |
except Exception as e:
|
| 257 |
print(f"Error: {e}")
|
| 258 |
|
|
|
|
| 5 |
import json
|
| 6 |
import datetime
|
| 7 |
import requests
|
| 8 |
+
import os.path
|
| 9 |
+
import gspread
|
| 10 |
|
| 11 |
import gradio_client
|
| 12 |
import gradio as gr
|
|
|
|
| 22 |
data_file_path = '/data/xp_data.json'
|
| 23 |
xp_data = {}
|
| 24 |
""""""
|
| 25 |
+
service_account = json.loads(os.environ.get('KEY'))
|
| 26 |
+
file_path = 'service_account.json'
|
| 27 |
+
with open(file_path, 'w') as json_file:
|
| 28 |
+
json.dump(service_account, json_file)
|
| 29 |
+
gspread_bot = gspread.service_account(filename='service_account.json')
|
| 30 |
+
worksheet = gspread_bot.open("levelbot").sheet1
|
| 31 |
+
""""""
|
| 32 |
|
| 33 |
API_URL = "https://api-inference.huggingface.co/models/mariagrandury/roberta-base-finetuned-sms-spam-detection"
|
| 34 |
HF_TOKEN = os.environ.get("HF_TOKEN", None)
|
|
|
|
| 254 |
# find all members with lvl13 role
|
| 255 |
members_with_role = [member.id for member in ctx.guild.members if lvl13 in member.roles]
|
| 256 |
# extract user_id + xp based on level
|
| 257 |
+
for member_id in members_with_role:
|
|
|
|
| 258 |
xp = calculate_xp(13)
|
| 259 |
level = calculate_level(xp+1)
|
| 260 |
+
user = await bot.fetch_user(member_id)
|
| 261 |
+
# get column name / data to safetycheck
|
| 262 |
+
worksheet.append_column([user.id], index=1)
|
| 263 |
+
worksheet.append_column([user.name], index=2)
|
| 264 |
+
worksheet.append_column([xp], index=3)
|
| 265 |
+
worksheet.append_column([level], index=4)
|
| 266 |
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
|
| 272 |
except Exception as e:
|
| 273 |
print(f"Error: {e}")
|
| 274 |
|