File size: 909 Bytes
a8e9b84 6175f34 a8e9b84 73f9dec 6175f34 73f9dec |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
import aiohttp
async def paste(text: str) -> str:
"""Pastes the given text to a pastebin service and returns the link."""
async with aiohttp.ClientSession() as session:
# Using a simple, no-login-required pastebin service like hastebin
try:
response = await session.post("https://hastebin.com/documents", data=text.encode('utf-8'))
response.raise_for_status() # Will raise an exception for 4xx/5xx status
result = await response.json()
return f"https://hastebin.com/{result['key']}"
except aiohttp.ClientError:
return "Failed to connect to pastebin service."
except Exception:
# Fallback for other errors, e.g., if the service changes its response
return "Failed to paste the content due to an unknown error."
# Alias for other parts of the code that expect DragBin
DragBin = paste
|