Captain Ezio commited on
Commit
5c52c2a
·
1 Parent(s): a42c137

Update utils.py

Browse files
Files changed (1) hide show
  1. Powers/plugins/utils.py +19 -18
Powers/plugins/utils.py CHANGED
@@ -263,31 +263,32 @@ async def paste(content: str):
263
 
264
  @Gojo.on_message(command("paste"))
265
  async def paste_func(_, message: Message):
266
- if not message.reply_to_message:
267
- content = message.text.split(None, 1)[1]
268
-
269
  r = message.reply_to_message
270
 
271
- if not r.text and not r.document:
272
- return await message.reply_text("Only text and documents are supported")
273
-
274
- m = await message.reply_text("Pasting...")
275
 
276
- if r.text:
277
- content = str(r.text)
278
- if r.document:
279
- if r.document.file_size > 40000:
280
- return await m.edit("You can only paste files smaller than 40KB.")
 
 
 
 
 
 
281
 
282
- if not pattern.search(r.document.mime_type):
283
- return await m.edit("Only text files can be pasted.")
284
 
285
- doc = await message.reply_to_message.download()
286
 
287
- async with aiofiles.open(doc, mode="r") as f:
288
- content = await f.read()
289
 
290
- remove(doc)
291
 
292
  link = await paste(content)
293
  kb = [[InlineKeyboardButton(text="Paste Link ", url=link)]]
 
263
 
264
  @Gojo.on_message(command("paste"))
265
  async def paste_func(_, message: Message):
 
 
 
266
  r = message.reply_to_message
267
 
268
+ if not r:
269
+ content = message.text.split(None, 1)[1]
 
 
270
 
271
+ if r:
272
+ if not r.text and not r.document:
273
+ return await message.reply_text("Only text and documents are supported")
274
+
275
+ m = await message.reply_text("Pasting...")
276
+
277
+ if r.text:
278
+ content = str(r.text)
279
+ if r.document:
280
+ if r.document.file_size > 40000:
281
+ return await m.edit("You can only paste files smaller than 40KB.")
282
 
283
+ if not pattern.search(r.document.mime_type):
284
+ return await m.edit("Only text files can be pasted.")
285
 
286
+ doc = await message.reply_to_message.download()
287
 
288
+ async with aiofiles.open(doc, mode="r") as f:
289
+ content = await f.read()
290
 
291
+ remove(doc)
292
 
293
  link = await paste(content)
294
  kb = [[InlineKeyboardButton(text="Paste Link ", url=link)]]