Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Merge main to modify-profile #39

Merged
merged 56 commits into from
Nov 7, 2023
Merged
Changes from 1 commit
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c8838fb
Refactored setup.py
quintindunn Oct 27, 2023
88bb1b3
Merge pull request #25 from quintindunn/setup-formatting
quintindunn Oct 27, 2023
7905bb6
Added SendKudosGQL
quintindunn Oct 27, 2023
2f5aca4
Added journal.send_kudos
quintindunn Oct 27, 2023
96717de
Added lapse.send_kudos
quintindunn Oct 27, 2023
4ef4a9a
Added examples/send_kudos_1.py
quintindunn Oct 27, 2023
0c9d761
Added render call to SendKudosGQL
quintindunn Oct 27, 2023
3156ddf
Moved Profile structure to structures/profile.py
quintindunn Oct 27, 2023
4453c6f
Moved Snap structure to structures/snap.py
quintindunn Oct 27, 2023
08dc5f1
Fixed import statements
quintindunn Oct 27, 2023
8d68fbb
Merge pull request #26 from quintindunn/friends-feed-revamp
quintindunn Oct 27, 2023
8e12b4f
Merge pull request #27 from quintindunn/structure-refactor
quintindunn Oct 27, 2023
0c15d86
Removed print statement from debugging
quintindunn Oct 27, 2023
32ef441
Removed print statement from debugging
quintindunn Oct 27, 2023
5155f28
Merge pull request #28 from quintindunn/Image-uploading
quintindunn Oct 27, 2023
f0b9ca9
Merge branch 'main' of https://github.com/quintindunn/lapsepy
quintindunn Oct 27, 2023
18d891c
Created friendsfeed structures
quintindunn Oct 28, 2023
2e3108c
Added FriendsFeed object generation
quintindunn Oct 28, 2023
b8a1ae8
Removed redundant nodes list decleration
quintindunn Oct 28, 2023
21f6ea9
Made FriendsFeed iterable
quintindunn Oct 28, 2023
a20f9ff
Added automatically adding of snaps to profile
quintindunn Oct 28, 2023
2c004dc
Updated examples/get_friends_feed/*
quintindunn Oct 28, 2023
c366236
Added music to profile from get_profile_by_id method
quintindunn Oct 28, 2023
446ca78
Added music to profile from Profile.from_dict method
quintindunn Oct 28, 2023
bdf7074
Fixed retrieval of artworkUrl and updated examples
quintindunn Oct 28, 2023
3391455
Merge pull request #29 from quintindunn/friends-feed-revamp
quintindunn Oct 28, 2023
64955bd
Merge pull request #30 from quintindunn/profile-revamp
quintindunn Oct 28, 2023
a5afe5c
Merge pull request #31 from quintindunn/docs
quintindunn Oct 28, 2023
532958e
Bumped version to 0.2.0
quintindunn Oct 28, 2023
24fdba4
Merge pull request #32 from quintindunn/version-bump-4
quintindunn Oct 28, 2023
91b7c0c
Fixed setup.py for pypi
quintindunn Oct 28, 2023
0599159
Bumped version to 0.2.1
quintindunn Oct 28, 2023
319d8bf
Merge pull request #33 from quintindunn/setup-fix
quintindunn Oct 28, 2023
43cc82f
Added StatusUpdateGQL
quintindunn Nov 5, 2023
91a4ffd
Created driving functions in journal.py & lapse.py
quintindunn Nov 5, 2023
61254a3
Wrapped up adding status updates
quintindunn Nov 5, 2023
ae82667
Added RemoveFriendFeedItemGQL
quintindunn Nov 5, 2023
5c3946c
Added remove_status_update in journal
quintindunn Nov 5, 2023
80a4c25
Added remove_status_update to lapse.py
quintindunn Nov 5, 2023
d5d4e26
Added remove example 1
quintindunn Nov 5, 2023
afedc49
Updated GQL query
quintindunn Nov 5, 2023
9e667f8
Fixed getting profile music
quintindunn Nov 5, 2023
65a6d02
Added catch if failed to get profile picture in examples/get_friends_…
quintindunn Nov 5, 2023
da2f27e
Revert "Added catch if failed to get profile picture in examples/get_…
quintindunn Nov 5, 2023
72c0439
Merge pull request #35 from quintindunn/friends-feed-update
quintindunn Nov 5, 2023
e8d5441
Fixed accidental revert of detecting failed profile picture retrieval
quintindunn Nov 5, 2023
52526d8
Merge pull request #36 from quintindunn/friends-feed-update
quintindunn Nov 5, 2023
2311713
Added driving code
quintindunn Nov 5, 2023
38550b3
Added reactions
quintindunn Nov 5, 2023
4c8c7d0
Added removing reactions
quintindunn Nov 5, 2023
8c66fec
Fixed examples
quintindunn Nov 5, 2023
0f819dc
Removed print statement from remove_status_update
quintindunn Nov 5, 2023
8288894
Added comment gql
quintindunn Nov 6, 2023
03a7929
Added sending comments
quintindunn Nov 6, 2023
d7263ea
Added comment structure
quintindunn Nov 6, 2023
d4932d1
Merge pull request #37 from quintindunn/reactions
quintindunn Nov 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added sending comments
quintindunn committed Nov 6, 2023
commit 03a79291fa3b37495daf7bf53e4cd95742feef34
10 changes: 10 additions & 0 deletions examples/delete_comment/delete_comment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os
from lapsepy.lapse import Lapse

if __name__ == '__main__':
lapse = Lapse(refresh_token=os.getenv("REFRESH_TOKEN"))

msg_id = input("Message ID: ")
comment = input("Comment: ")

lapse.delete_comment(msg_id=msg_id, comment_id=comment)
10 changes: 10 additions & 0 deletions examples/send_comment/send_comment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os
from lapsepy.lapse import Lapse

if __name__ == '__main__':
lapse = Lapse(refresh_token=os.getenv("REFRESH_TOKEN"))

msg_id = input("Message ID: ")
comment = input("Comment: ")

lapse.send_comment(msg_id=msg_id, text=comment)
19 changes: 19 additions & 0 deletions lapsepy/journal/factory/media_factory.py
Original file line number Diff line number Diff line change
@@ -226,3 +226,22 @@ def _render_variables(self):
"mediaId": self.msg_id,
"text": self.text
}


class DeleteCommentGQL(BaseGQL):
def __init__(self, comment_id: str, msg_id: str):
super().__init__("DeleteCommentGraphQLMutation",
"mutation DeleteCommentGraphQLMutation($input: DeleteMediaCommentInput!) "
"{ deleteMediaComment(input: $input) { __typename success } }")
self.comment_id = comment_id
self.msg_id = msg_id

self.variables = {}

self._render_variables()

def _render_variables(self):
self.variables['input'] = {
"id": self.comment_id,
"mediaId": self.msg_id,
}
31 changes: 30 additions & 1 deletion lapsepy/journal/journal.py
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@

from .factory.friends_factory import FriendsFeedItemsGQL, ProfileDetailsGQL, SendKudosGQL
from .factory.media_factory import ImageUploadURLGQL, CreateMediaGQL, SendInstantsGQL, StatusUpdateGQL, \
RemoveFriendsFeedItemGQL, AddReactionGQL, RemoveReactionGQL
RemoveFriendsFeedItemGQL, AddReactionGQL, RemoveReactionGQL, SendCommentGQL, DeleteCommentGQL
from lapsepy.journal.factory.profile_factory import SaveBioGQL, SaveDisplayNameGQL, SaveUsernameGQL, SaveEmojisGQL, \
SaveDOBGQL

@@ -406,3 +406,32 @@ def remove_reaction(self, msg_id: str, reaction: str):

if not response.get('data', {}).get("removeMediaReaction", {}).get("success"):
raise SyncJournalException("Error removing reaction.")

def create_comment(self, msg_id: str, text: str, comment_id: str | None = None):
"""
Adds a comment to a post
:param comment_id: id of the comment, leave as None unless you know what you're doing
:param msg_id: id of the message
:param text: text to send in the comment
:return:
"""
if comment_id is None:
comment_id = "01HEH" + str(uuid4()).upper().replace("-", "")[:20]
query = SendCommentGQL(comment_id=comment_id, msg_id=msg_id, text=text).to_dict()
response = self._sync_journal_call(query)

if not response.get('data', {}).get("sendMediaComment", {}).get("success"):
raise SyncJournalException("Error sending comment.")

def delete_comment(self, msg_id: str, comment_id: str):
"""
Deletes a comment from a lapsepy post
:param msg_id: ID of the post
:param comment_id: ID of the comment
:return:
"""
query = DeleteCommentGQL(msg_id=msg_id, comment_id=comment_id).to_dict()
response = self._sync_journal_call(query)

if not response.get('data', {}).get("deleteMediaComment", {}).get("success"):
raise SyncJournalException("Error deleting comment.")
21 changes: 20 additions & 1 deletion lapsepy/lapse/lapse.py
Original file line number Diff line number Diff line change
@@ -193,4 +193,23 @@ def remove_reaction(self, msg_id: str, reaction: str):
:param reaction: Reaction to remove.
:return:
"""
return self.journal.remove_reaction(msg_id=msg_id, reaction=reaction)
return self.journal.remove_reaction(msg_id=msg_id, reaction=reaction)

def send_comment(self, msg_id: str, text: str, comment_id: str | None = None):
"""
Adds a comment to a post
:param comment_id: id of the comment, leave as None unless you know what you're doing
:param msg_id: id of the message
:param text: text to send in the comment
:return:
"""
return self.journal.create_comment(msg_id=msg_id, text=text, comment_id=comment_id)

def delete_comment(self, msg_id: str, comment_id: str):
"""
Deletes a comment from a lapsepy post
:param msg_id: ID of the post
:param comment_id: ID of the comment
:return:
"""
return self.journal.delete_comment(msg_id=msg_id, comment_id=comment_id)