diff options
-rw-r--r-- | pypaste/client/plugins/pgz/__init__.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pypaste/client/plugins/pgz/__init__.py b/pypaste/client/plugins/pgz/__init__.py new file mode 100644 index 0000000..a916c19 --- /dev/null +++ b/pypaste/client/plugins/pgz/__init__.py @@ -0,0 +1,24 @@ +import io +import requests +from pypaste.client import PasteService +from pypaste.client.plugins import register_service +from typing import Optional, List + +URL: str = "https://paste.gentoo.zip" + +@register_service("pgz") +class Pgz: + + def paste(self, buffer: io.BytesIO, syntax: Optional[str], raw: bool) -> str: + files = {"file": ("pypaste-upload", buffer, "multipart/form-data")} + + req = requests.post(URL, files=files) + + if req.status_code != 200: + raise Exception(f"failed to paste to pgz: status code: {req.status_code}") + + return req.text.strip() + + + def supported_syntaxes(self) -> List[str]: + return [] |