taslim19 commited on
Commit
6175f34
·
1 Parent(s): 55c6269

fix: Add paste function to resolve ImportError

Browse files
Files changed (1) hide show
  1. DragMusic/utils/pastebin.py +9 -18
DragMusic/utils/pastebin.py CHANGED
@@ -1,21 +1,12 @@
1
  import aiohttp
2
 
3
- BASE = "https://batbin.me/"
4
-
5
-
6
- async def post(url: str, *args, **kwargs):
7
  async with aiohttp.ClientSession() as session:
8
- async with session.post(url, *args, **kwargs) as resp:
9
- try:
10
- data = await resp.json()
11
- except Exception:
12
- data = await resp.text()
13
- return data
14
-
15
-
16
- async def DragBin(text):
17
- resp = await post(f"{BASE}api/v2/paste", data=text)
18
- if not resp["success"]:
19
- return
20
- link = BASE + resp["message"]
21
- return link
 
1
  import aiohttp
2
 
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."