Compare commits
No commits in common. "main" and "main" have entirely different histories.
@ -30,4 +30,8 @@ async def list_rants():
|
|||||||
```
|
```
|
||||||
See [tests](src/devranta/tests.py) for [examples](src/devranta/tests.py) on how to use.
|
See [tests](src/devranta/tests.py) for [examples](src/devranta/tests.py) on how to use.
|
||||||
|
|
||||||
|
## Todo
|
||||||
|
|
||||||
|
- voting comment
|
||||||
|
- edit message
|
||||||
|
|
||||||
|
BIN
dist/devranta-1.0.0-py3-none-any.whl
vendored
BIN
dist/devranta-1.0.0-py3-none-any.whl
vendored
Binary file not shown.
BIN
dist/devranta-1.0.0.tar.gz
vendored
BIN
dist/devranta-1.0.0.tar.gz
vendored
Binary file not shown.
@ -43,4 +43,8 @@ async def list_rants():
|
|||||||
```
|
```
|
||||||
See [tests](src/devranta/tests.py) for [examples](src/devranta/tests.py) on how to use.
|
See [tests](src/devranta/tests.py) for [examples](src/devranta/tests.py) on how to use.
|
||||||
|
|
||||||
|
## Todo
|
||||||
|
|
||||||
|
- voting comment
|
||||||
|
- edit message
|
||||||
|
|
||||||
|
@ -1,11 +1,5 @@
|
|||||||
from typing import Literal, Optional
|
|
||||||
import aiohttp
|
import aiohttp
|
||||||
from enum import Enum
|
|
||||||
|
|
||||||
class VoteReason(Enum):
|
|
||||||
NOT_FOR_ME = 0
|
|
||||||
REPOST = 1
|
|
||||||
OFFENSIVE_SPAM = 2
|
|
||||||
|
|
||||||
class Api:
|
class Api:
|
||||||
|
|
||||||
@ -71,23 +65,6 @@ class Api:
|
|||||||
await self.session.close()
|
await self.session.close()
|
||||||
self.session = None
|
self.session = None
|
||||||
|
|
||||||
async def register_user(self, email, username, password):
|
|
||||||
response = None
|
|
||||||
async with self as session:
|
|
||||||
response = await session.post(
|
|
||||||
url=self.patch_url(f"users"),
|
|
||||||
data=self.patch_auth({
|
|
||||||
"email": email,
|
|
||||||
"username": username,
|
|
||||||
"password": password,
|
|
||||||
"plat": 3
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
if not response:
|
|
||||||
return False
|
|
||||||
obj = await response.json()
|
|
||||||
return obj.get('success', False)
|
|
||||||
|
|
||||||
async def get_comments_from_user(self, username):
|
async def get_comments_from_user(self, username):
|
||||||
user_id = await self.get_user_id(username)
|
user_id = await self.get_user_id(username)
|
||||||
profile = await self.get_profile(user_id)
|
profile = await self.get_profile(user_id)
|
||||||
@ -191,28 +168,6 @@ class Api:
|
|||||||
obj = await response.json()
|
obj = await response.json()
|
||||||
return obj.get("success", False)
|
return obj.get("success", False)
|
||||||
|
|
||||||
async def vote_rant(self, rant_id: int, vote: Literal[-1, 0, 1], reason: Optional[VoteReason] = None):
|
|
||||||
if not await self.ensure_login():
|
|
||||||
return None
|
|
||||||
async with self as session:
|
|
||||||
response = await session.post(
|
|
||||||
url=self.patch_url(f"devrant/rants/{rant_id}/vote"),
|
|
||||||
data=self.patch_auth({"vote": vote, "reason": reason.value if reason else None}),
|
|
||||||
)
|
|
||||||
obj = await response.json()
|
|
||||||
return obj.get("success", False)
|
|
||||||
|
|
||||||
async def vote_comment(self, comment_id: int, vote: Literal[-1, 0, 1], reason: Optional[VoteReason] = None):
|
|
||||||
if not await self.ensure_login():
|
|
||||||
return None
|
|
||||||
async with self as session:
|
|
||||||
response = await session.post(
|
|
||||||
url=self.patch_url(f"comments/{comment_id}/vote"),
|
|
||||||
data=self.patch_auth({"vote": vote, "reason": reason.value if reason else None}),
|
|
||||||
)
|
|
||||||
obj = await response.json()
|
|
||||||
return obj.get("success", False)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
async def notifs(self):
|
async def notifs(self):
|
||||||
response = None
|
response = None
|
||||||
|
Loading…
Reference in New Issue
Block a user