lunarflu HF staff commited on
Commit
ab6239f
1 Parent(s): 0ca9f8f

Synced repo using 'sync_with_huggingface' Github Action

Browse files
Files changed (1) hide show
  1. app.py +3 -29
app.py CHANGED
@@ -19,8 +19,6 @@ bot = commands.Bot(command_prefix='!', intents=intents)
19
 
20
  """"""
21
  XP_PER_MESSAGE = 10 # 100k messages = 1M exp = lvl 100
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'
@@ -32,9 +30,12 @@ worksheet = gspread_bot.open("levelbot").sheet1
32
  API_URL = "https://api-inference.huggingface.co/models/mariagrandury/roberta-base-finetuned-sms-spam-detection"
33
  HF_TOKEN = os.environ.get("HF_TOKEN", None)
34
  headers = {"Authorization": f"Bearer {HF_TOKEN}"}
 
35
  def query(payload):
36
  response = requests.post(API_URL, headers=headers, json=payload)
37
  return response.json()
 
 
38
  """"""
39
 
40
  @bot.event
@@ -97,12 +98,9 @@ async def on_message(message):
97
  # update exp, can only be in a positive direction
98
  # read
99
  xp = worksheet.cell(cell.row, cell.col+2).value
100
- print("debug")
101
  xp = int(xp) + XP_PER_MESSAGE
102
- print("debug")
103
  current_level = calculate_level(xp)
104
  print(current_level)
105
- print("debug")
106
  # write with added xp
107
  worksheet.update(values=[[xp, current_level]], range_name=f'C{cell.row}:D{cell.row}')
108
  print("debug")
@@ -217,30 +215,6 @@ async def on_message(message):
217
 
218
  except Exception as e:
219
  print(f"Error: {e}")
220
-
221
-
222
- @bot.command()
223
- async def fixsheets(ctx):
224
- if ctx.author.id == 811235357663297546:
225
- try:
226
- # iterate through @verified role members
227
-
228
- # test in test sheet first
229
-
230
- role_id = int(900063512829755413) # 900063512829755413 = @verified
231
- role = discord.utils.get(ctx.guild.roles, id=role_id)
232
-
233
- if role is None:
234
- print(f"Role with ID '{role_id}' not found.")
235
- return
236
-
237
- members_with_role = [member.id for member in ctx.guild.members if role in member.roles]
238
-
239
- print(f"Members with the role with ID '{role_id}': {', '.join(map(str, members_with_role))}")
240
-
241
-
242
- except Exception as e:
243
- print(f"Error: {e}")
244
 
245
 
246
  @bot.command()
 
19
 
20
  """"""
21
  XP_PER_MESSAGE = 10 # 100k messages = 1M exp = lvl 100
 
 
22
  """"""
23
  service_account = json.loads(os.environ.get('KEY'))
24
  file_path = 'service_account.json'
 
30
  API_URL = "https://api-inference.huggingface.co/models/mariagrandury/roberta-base-finetuned-sms-spam-detection"
31
  HF_TOKEN = os.environ.get("HF_TOKEN", None)
32
  headers = {"Authorization": f"Bearer {HF_TOKEN}"}
33
+ """
34
  def query(payload):
35
  response = requests.post(API_URL, headers=headers, json=payload)
36
  return response.json()
37
+ """
38
+
39
  """"""
40
 
41
  @bot.event
 
98
  # update exp, can only be in a positive direction
99
  # read
100
  xp = worksheet.cell(cell.row, cell.col+2).value
 
101
  xp = int(xp) + XP_PER_MESSAGE
 
102
  current_level = calculate_level(xp)
103
  print(current_level)
 
104
  # write with added xp
105
  worksheet.update(values=[[xp, current_level]], range_name=f'C{cell.row}:D{cell.row}')
106
  print("debug")
 
215
 
216
  except Exception as e:
217
  print(f"Error: {e}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
 
219
 
220
  @bot.command()