Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
d60 authored Apr 23, 2024
1 parent 89789c9 commit c800d13
Show file tree
Hide file tree
Showing 11 changed files with 575 additions and 52 deletions.
3 changes: 2 additions & 1 deletion twikit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
A Python library for interacting with the Twitter API.
"""

__version__ = '1.5.5'
__version__ = '1.5.6'

from .bookmark import BookmarkFolder
from .client import Client
from .community import (Community, CommunityCreator, CommunityMember,
CommunityRule)
Expand Down
62 changes: 62 additions & 0 deletions twikit/bookmark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from httpx import Response

from .client import Client
from .tweet import Tweet
from .utils import Result


class BookmarkFolder:
"""
Attributes
----------
id : :class:`str`
The ID of the folder.
name : :class:`str`
The name of the folder
media : :class:`str`
Icon image data.
"""
def __init__(self, client: Client, data: dict) -> None:
self._client = client

self.id: str = data['id']
self.name: str = data['name']
self.media: dict = data['media']

def get_tweets(self, cursor: str | None = None) -> Result[Tweet]:
"""
Retrieves tweets from the folder.
"""
return self._client.get_bookmarks(cursor=cursor, folder_id=self.id)

def edit(self, name: str) -> BookmarkFolder:
"""
Edits the folder.
"""
return self._client.edit_bookmark_folder(self.id, name)

def delete(self) -> Response:
"""
Deletes the folder.
"""
return self._client.delete_bookmark_folder(self.id)

def add(self, tweet_id: str) -> Response:
"""
Adds a tweet to the folder.
"""
return self._client.bookmark_tweet(tweet_id, self.id)

def __eq__(self, __value: object) -> bool:
return isinstance(__value, BookmarkFolder) and self.id == __value.id

def __ne__(self, __value: object) -> bool:
return not self == __value

def __repr__(self) -> str:
return f'<BookmarkFolder id="{self.id}">'
Loading

0 comments on commit c800d13

Please sign in to comment.