Rifat Azad commited on
Commit
73001f4
·
1 Parent(s): b60bc2a

imrovements 3

Browse files
Files changed (1) hide show
  1. pydvpl_bot.py +14 -2
pydvpl_bot.py CHANGED
@@ -81,13 +81,19 @@ async def decompress_file(file_path):
81
  @bot.command(help="Compresses attached files.")
82
  async def compress(ctx):
83
  attachments = ctx.message.attachments
84
-
85
  if not attachments:
86
  await ctx.send("No file attached.")
87
  return
88
 
89
  for attachment in attachments:
90
  file_path = os.path.join("received_to_compress", attachment.filename)
 
 
 
 
 
 
91
  await attachment.save(file_path)
92
  compressed_file_path = await compress_file(file_path)
93
  if compressed_file_path:
@@ -101,13 +107,19 @@ async def compress(ctx):
101
  @bot.command(help="Decompresses attached files.")
102
  async def decompress(ctx):
103
  attachments = ctx.message.attachments
104
-
105
  if not attachments:
106
  await ctx.send("No file attached.")
107
  return
108
 
109
  for attachment in attachments:
110
  file_path = os.path.join("received_to_decompress", attachment.filename)
 
 
 
 
 
 
111
  await attachment.save(file_path)
112
  decompressed_file_path = await decompress_file(file_path)
113
  if decompressed_file_path:
 
81
  @bot.command(help="Compresses attached files.")
82
  async def compress(ctx):
83
  attachments = ctx.message.attachments
84
+
85
  if not attachments:
86
  await ctx.send("No file attached.")
87
  return
88
 
89
  for attachment in attachments:
90
  file_path = os.path.join("received_to_compress", attachment.filename)
91
+
92
+ # Check if the file is already in .dvpl format, if so, skip it
93
+ if file_path.endswith(".dvpl"):
94
+ await ctx.send(f"File {attachment.filename} is already in .dvpl format. Skipping.")
95
+ continue
96
+
97
  await attachment.save(file_path)
98
  compressed_file_path = await compress_file(file_path)
99
  if compressed_file_path:
 
107
  @bot.command(help="Decompresses attached files.")
108
  async def decompress(ctx):
109
  attachments = ctx.message.attachments
110
+
111
  if not attachments:
112
  await ctx.send("No file attached.")
113
  return
114
 
115
  for attachment in attachments:
116
  file_path = os.path.join("received_to_decompress", attachment.filename)
117
+
118
+ # Check if the file is not in .dvpl format, if so, skip it
119
+ if not file_path.endswith(".dvpl"):
120
+ await ctx.send(f"File {attachment.filename} is not in .dvpl format. Skipping.")
121
+ continue
122
+
123
  await attachment.save(file_path)
124
  decompressed_file_path = await decompress_file(file_path)
125
  if decompressed_file_path: