Spaces:
Paused
Paused
Captain Ezio
commited on
Commit
·
624601b
1
Parent(s):
63f642d
Update utils.py
Browse files- Powers/plugins/utils.py +6 -12
Powers/plugins/utils.py
CHANGED
|
@@ -251,21 +251,13 @@ async def github(_, m: Message):
|
|
| 251 |
|
| 252 |
session = ClientSession()
|
| 253 |
pattern = re.compile(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$")
|
| 254 |
-
BASE = "https://
|
| 255 |
-
|
| 256 |
-
async def post(url: str, *args, **kwargs):
|
| 257 |
-
async with session.post(url, *args, **kwargs) as resp:
|
| 258 |
-
try:
|
| 259 |
-
data = await resp.json()
|
| 260 |
-
except Exception:
|
| 261 |
-
data = await resp.text()
|
| 262 |
-
return data
|
| 263 |
|
| 264 |
async def paste(content: str):
|
| 265 |
resp = await post(f"{BASE}api/v2/paste", data=content)
|
| 266 |
if not resp["success"]:
|
| 267 |
return
|
| 268 |
-
return BASE + resp["
|
| 269 |
|
| 270 |
|
| 271 |
@Gojo.on_message(command("paste"))
|
|
@@ -299,11 +291,13 @@ async def paste_func(_, message: Message):
|
|
| 299 |
|
| 300 |
link = await paste(content)
|
| 301 |
kb = [[InlineKeyboardButton(text="Paste Link ", url=link)]]
|
|
|
|
| 302 |
try:
|
| 303 |
-
await m.delete()
|
| 304 |
await message.reply_text("Here's your paste", reply_markup=InlineKeyboardMarkup(kb))
|
| 305 |
except Exception:
|
| 306 |
-
|
|
|
|
|
|
|
| 307 |
|
| 308 |
|
| 309 |
@Gojo.on_message(command("tr"))
|
|
|
|
| 251 |
|
| 252 |
session = ClientSession()
|
| 253 |
pattern = re.compile(r"^text/|json$|yaml$|xml$|toml$|x-sh$|x-shellscript$")
|
| 254 |
+
BASE = "https://pasty.lus.pm/"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 255 |
|
| 256 |
async def paste(content: str):
|
| 257 |
resp = await post(f"{BASE}api/v2/paste", data=content)
|
| 258 |
if not resp["success"]:
|
| 259 |
return
|
| 260 |
+
return BASE + resp["id"]
|
| 261 |
|
| 262 |
|
| 263 |
@Gojo.on_message(command("paste"))
|
|
|
|
| 291 |
|
| 292 |
link = await paste(content)
|
| 293 |
kb = [[InlineKeyboardButton(text="Paste Link ", url=link)]]
|
| 294 |
+
await m.delete()
|
| 295 |
try:
|
|
|
|
| 296 |
await message.reply_text("Here's your paste", reply_markup=InlineKeyboardMarkup(kb))
|
| 297 |
except Exception:
|
| 298 |
+
if link:
|
| 299 |
+
return await message.reply_text(f"Here's your paste:\n [link]({link})",)
|
| 300 |
+
return await message.reply_text("Failed to post")
|
| 301 |
|
| 302 |
|
| 303 |
@Gojo.on_message(command("tr"))
|