-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #219 from SylteA/dev
Dev
- Loading branch information
Showing
4 changed files
with
62 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from pydantic import BaseModel | ||
|
||
from bot.config import settings | ||
from bot.services import http | ||
|
||
|
||
class Document(BaseModel): | ||
key: str | ||
|
||
@property | ||
def url(self) -> str: | ||
return settings.hastebin.base_url + "/" + self.key | ||
|
||
|
||
async def create(content: str) -> Document: | ||
"""Creates a hastebin Document with the provided content.""" | ||
async with http.session.post(settings.hastebin.base_url + "/documents", data=content) as response: | ||
response.raise_for_status() | ||
|
||
data = await response.json() | ||
return Document(**data) |