MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / post_comment

Method post_comment

scratchattach/site/project.py:688–720  ·  view source on GitHub ↗

Posts a comment on the project. You can only use this function if this object was created using :meth:`scratchattach.session.Session.connect_project` Args: content: Content of the comment that should be posted Keyword Arguments: parent_id: ID of the

(self, content, *, parent_id="", commentee_id="")

Source from the content-addressed store, hash-verified

686 )
687
688 def post_comment(self, content, *, parent_id="", commentee_id=""):
689 """
690 Posts a comment on the project. You can only use this function if this object was created using :meth:`scratchattach.session.Session.connect_project`
691
692 Args:
693 content: Content of the comment that should be posted
694
695 Keyword Arguments:
696 parent_id: ID of the comment you want to reply to. If you don't want to mention a user, don't put the argument.
697 commentee_id: ID of the user that will be mentioned in your comment and will receive a message about your comment. If you don't want to mention a user, don't put the argument.
698
699 Returns:
700 scratchattach.comments.Comment: Comment object representing the posted comment.
701 """
702 self._assert_auth()
703 data = {
704 "commentee_id": commentee_id,
705 "content": str(content),
706 "parent_id": parent_id,
707 }
708 r = json.loads(
709 requests.post(
710 f"https://api.scratch.mit.edu/proxy/comments/project/{self.id}/",
711 headers=(self._json_headers | {"referer": "https://scratch.mit.edu/projects/" + str(self.id) + "/"}),
712 cookies=self._cookies,
713 data=json.dumps(data),
714 ).text
715 )
716 if "id" not in r:
717 raise exceptions.CommentPostFailure(r)
718 _comment = comment.Comment(id=r["id"], _session=self._session, source=comment.CommentSource.PROJECT, source_id=self.id)
719 _comment._update_from_dict(r)
720 return _comment
721
722 def reply_comment(self, content, *, parent_id, commentee_id=""):
723 """

Callers 1

reply_commentMethod · 0.95

Calls 3

_update_from_dictMethod · 0.95
postMethod · 0.80
_assert_authMethod · 0.45

Tested by

no test coverage detected