taslim19 commited on
Commit
73f9dec
·
1 Parent(s): 6175f34

fix: Add DragBin alias to pastebin

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