Skip to content

Commit 291670a

Browse files
committed
add get raw paste capability
1 parent 48ab5d8 commit 291670a

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

mystbin/client.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from __future__ import annotations
2424

2525
import datetime
26-
from typing import List, Optional, Sequence, overload
26+
from typing import List, Literal, Optional, Sequence, overload
2727

2828
import aiohttp
2929

@@ -174,7 +174,15 @@ async def delete_pastes(self, paste_ids: List[str], /) -> None:
174174
"""
175175
await self.http.delete_pastes(paste_ids=paste_ids)
176176

177-
async def get_paste(self, paste_id: str, *, password: Optional[str] = None) -> Paste:
177+
@overload
178+
async def get_paste(self, paste_id: str, *, password: Optional[str] = ..., raw: Literal[False]) -> Paste:
179+
...
180+
181+
@overload
182+
async def get_paste(self, paste_id: str, *, password: Optional[str] = ..., raw: Literal[True]) -> list[str]:
183+
...
184+
185+
async def get_paste(self, paste_id: str, *, password: Optional[str] = None, raw: bool = False) -> Paste | list[str]:
178186
"""|coro|
179187
180188
Fetch a paste.
@@ -187,6 +195,8 @@ async def get_paste(self, paste_id: str, *, password: Optional[str] = None) -> P
187195
The password of the paste, if any.
188196
"""
189197
data = await self.http.get_paste(paste_id=paste_id, password=password)
198+
if raw:
199+
return [item["content"] for item in data["files"]]
190200
return Paste.from_data(data)
191201

192202
@require_authentication

0 commit comments

Comments
 (0)