Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
43ff66e
1
Parent(s):
cbc9e11
Update utils.py
Browse files- 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
|
| 272 |
-
|
| 273 |
-
|
| 274 |
-
m = await message.reply_text("Pasting...")
|
| 275 |
|
| 276 |
-
if r
|
| 277 |
-
|
| 278 |
-
|
| 279 |
-
|
| 280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 281 |
|
| 282 |
-
|
| 283 |
-
|
| 284 |
|
| 285 |
-
|
| 286 |
|
| 287 |
-
|
| 288 |
-
|
| 289 |
|
| 290 |
-
|
| 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)]]
|