Posts a reply comment to the comment. Warning: Scratch only shows comments replying to top-level comments, and all replies to replies are actually replies to top-level comments in the API. Therefore, if this comment is a reply, this method will not
(self, content, *, commentee_id=None)
| 147 | # Methods for dealing with the comment |
| 148 | |
| 149 | def reply(self, content, *, commentee_id=None): |
| 150 | """ |
| 151 | Posts a reply comment to the comment. |
| 152 | |
| 153 | Warning: |
| 154 | Scratch only shows comments replying to top-level comments, and all replies to replies are actually replies to top-level comments in the API. |
| 155 | |
| 156 | Therefore, if this comment is a reply, this method will not reply to the comment itself but to the corresponding top-level comment. |
| 157 | |
| 158 | Args: |
| 159 | content (str): Comment content to post. |
| 160 | |
| 161 | Keyword args: |
| 162 | commentee_id (None or str): If set to None (default), it will automatically fill out the commentee ID with the user ID of the parent comment author. Set it to "" to mention no user. |
| 163 | |
| 164 | |
| 165 | Returns: |
| 166 | scratchattach.Comment: The created comment. |
| 167 | :param content: Content of the comment to send |
| 168 | :param commentee_id: ID of user to reply to |
| 169 | """ |
| 170 | |
| 171 | self._assert_auth() |
| 172 | parent_id = str(self.id) |
| 173 | if self.parent_id is not None: |
| 174 | parent_id = str(self.parent_id) |
| 175 | if commentee_id is None: |
| 176 | if self.author_id: |
| 177 | commentee_id = self.author_id |
| 178 | else: |
| 179 | commentee_id = "" |
| 180 | |
| 181 | if self.source == CommentSource.USER_PROFILE: |
| 182 | return user.User(username=self.source_id, _session=self._session).reply_comment(content, |
| 183 | parent_id=str(parent_id), |
| 184 | commentee_id=commentee_id) |
| 185 | if self.source == CommentSource.PROJECT: |
| 186 | p = project.Project(id=self.source_id, _session=self._session) |
| 187 | p.update() |
| 188 | return p.reply_comment(content, parent_id=str(parent_id), commentee_id=commentee_id) |
| 189 | |
| 190 | if self.source == CommentSource.STUDIO: |
| 191 | return studio.Studio(id=self.source_id, _session=self._session).reply_comment(content, |
| 192 | parent_id=str(parent_id), |
| 193 | commentee_id=commentee_id) |
| 194 | raise ValueError(f"Unknown source: {self.source}") |
| 195 | |
| 196 | def delete(self): |
| 197 | """ |
nothing calls this directly
no test coverage detected