Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error fetching comment by ID #336

Open
uukelele-scratch opened this issue Jan 26, 2025 · 8 comments
Open

Error fetching comment by ID #336

uukelele-scratch opened this issue Jan 26, 2025 · 8 comments

Comments

@uukelele-scratch
Copy link

Traceback (most recent call last):
  File "main.py", line 160, in replyComment
    comment_obj = user.comment_by_id(commentID)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/.local/lib/python3.11/site-packages/scratchattach/site/user.py", line 730, in comment_by_id
    results = list(filter(lambda x : str(x.id) == str(comment_id), page_content))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not iterable

When I'm replying using the ID of a root-level comment it works fine, but as soon as I attempt to reply using the ID of a reply this error is thrown.

I can't even try replying to the comment with its parent, as I can't even get the comment_obj.

Here's more of my code:

def replyComment(comment, user, commentID):
        user = session.connect_user(user)
        comment_obj = user.comment_by_id(commentID)
        comment_obj.reply(comment)
        return "Comment replied to successfully!"
@FAReTek1
Copy link
Collaborator

I have recently also had problems with the comment system, and found some quirks/scratchattach didn't work for me.
Perhaps there was an update to the API (possibly at the time when using commentee-id to get username by id was removed) which caused the scratchattach library to go out of date in this respect. It might be something to be investigated

@abhiramtx
Copy link
Contributor

Hello! Only replies to top-level comments are shown on the Scratch website. Replies to replies are actually replies to the corresponding top-level comment in the API and aren't different in any way. Thus, you will have to use the parent id of the original comment when trying to reply. The correct syntax to reply to a comment is: user.reply_comment("comment content", parent_id="parent_id", commentee_id=""). Use the commentee_id to notify a user / ping a user about the message (put their user_id) (that is also how replies are handled in the API).

@uukelele-scratch
Copy link
Author

Hello! Only replies to top-level comments are shown on the Scratch website. Replies to replies are actually replies to the corresponding top-level comment in the API and aren't different in any way. Thus, you will have to use the parent id of the original comment when trying to reply. The correct syntax to reply to a comment is: user.reply_comment("comment content", parent_id="parent_id", commentee_id=""). Use the commentee_id to notify a user / ping a user about the message (put their user_id) (that is also how replies are handled in the API).

What you're saying I should do is use the comment ID to get a comment object, then use the parent comment method of that comment to find the parent comment, and finally reply to the parent comment.

However, I can't even get the comment object from the comment ID.

@TheCommCraft
Copy link
Collaborator

TheCommCraft commented Jan 28, 2025 via email

@TheCommCraft
Copy link
Collaborator

TheCommCraft commented Jan 28, 2025 via email

@TheCommCraft
Copy link
Collaborator

TheCommCraft commented Jan 28, 2025 via email

@TheCommCraft
Copy link
Collaborator

TheCommCraft commented Jan 28, 2025 via email

@uukelele-scratch
Copy link
Author

uukelele-scratch commented Jan 28, 2025

Interesting. Sometimes, when viewing the comments page, recent comments don't show. Perhaps something needs to be added in this function to handle empty comment pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants