Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
read from discord
Browse files
app.py
CHANGED
|
@@ -342,12 +342,13 @@ async def xp_help(ctx):
|
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
-
@bot.command(
|
| 346 |
async def test3(ctx):
|
| 347 |
if ctx.author.id == 811235357663297546:
|
| 348 |
worksheet = gspread_bot.open("levelbot").sheet1
|
| 349 |
values = worksheet.get_all_values()
|
| 350 |
target_id = '811235357663297546'
|
|
|
|
| 351 |
|
| 352 |
csv_file_path = 'test3.csv'
|
| 353 |
with open(csv_file_path, 'w', newline='') as csv_file:
|
|
@@ -370,7 +371,7 @@ async def test3(ctx):
|
|
| 370 |
|
| 371 |
# +10
|
| 372 |
try:
|
| 373 |
-
row[cell_to_increment_index] = str(int(row[cell_to_increment_index]) +
|
| 374 |
print(row[cell_to_increment_index])
|
| 375 |
except (IndexError, ValueError):
|
| 376 |
print(f"Error: Unable to increment cell at index {cell_to_increment_index}")
|
|
@@ -400,6 +401,27 @@ async def test3(ctx):
|
|
| 400 |
# recover csv from discord channel, read into memory
|
| 401 |
|
| 402 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 403 |
|
| 404 |
|
| 405 |
"""
|
|
|
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
+
@bot.command()
|
| 346 |
async def test3(ctx):
|
| 347 |
if ctx.author.id == 811235357663297546:
|
| 348 |
worksheet = gspread_bot.open("levelbot").sheet1
|
| 349 |
values = worksheet.get_all_values()
|
| 350 |
target_id = '811235357663297546'
|
| 351 |
+
variable_xp = 0
|
| 352 |
|
| 353 |
csv_file_path = 'test3.csv'
|
| 354 |
with open(csv_file_path, 'w', newline='') as csv_file:
|
|
|
|
| 371 |
|
| 372 |
# +10
|
| 373 |
try:
|
| 374 |
+
row[cell_to_increment_index] = str(int(row[cell_to_increment_index]) + variable_xp)
|
| 375 |
print(row[cell_to_increment_index])
|
| 376 |
except (IndexError, ValueError):
|
| 377 |
print(f"Error: Unable to increment cell at index {cell_to_increment_index}")
|
|
|
|
| 401 |
# recover csv from discord channel, read into memory
|
| 402 |
|
| 403 |
|
| 404 |
+
@bot.command()
|
| 405 |
+
async def read_csv(ctx):
|
| 406 |
+
if ctx.author.id == 811235357663297546:
|
| 407 |
+
async for message in ctx.channel.history(limit=1):
|
| 408 |
+
if message.attachments:
|
| 409 |
+
attachment = message.attachments[0]
|
| 410 |
+
if attachment.filename.endswith('.csv'):
|
| 411 |
+
csv_content = await attachment.read()
|
| 412 |
+
csv_data = []
|
| 413 |
+
csv_lines = csv_content.decode('utf-8').splitlines()
|
| 414 |
+
csv_reader = csv.reader(csv_lines)
|
| 415 |
+
for row in csv_reader:
|
| 416 |
+
csv_data.append(row)
|
| 417 |
+
print(csv_data)
|
| 418 |
+
|
| 419 |
+
await ctx.send("discord -> read -> updated HF Hub")
|
| 420 |
+
break
|
| 421 |
+
else:
|
| 422 |
+
await ctx.send("The latest attachment is not a CSV file.")
|
| 423 |
+
else:
|
| 424 |
+
await ctx.send("No attachments found in the latest message.")
|
| 425 |
|
| 426 |
|
| 427 |
"""
|