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

Method comment_by_id

scratchattach/site/user.py:1095–1123  ·  view source on GitHub ↗

Gets a comment on this user's profile by id. Warning: For comments very far down on the user's profile, this method will take a while to find the comment. Very old comment are deleted from Scratch's database and may not appear. Returns: scratchattac

(self, comment_id)

Source from the content-addressed store, hash-verified

1093 return data
1094
1095 def comment_by_id(self, comment_id) -> comment.Comment:
1096 """
1097 Gets a comment on this user's profile by id.
1098
1099 Warning:
1100 For comments very far down on the user's profile, this method will take a while to find the comment. Very old comment are deleted from Scratch's database and may not appear.
1101
1102 Returns:
1103 scratchattach.comments.Comment: The request comment.
1104 """
1105
1106 page = 1
1107 page_content = self.comments(page=page)
1108 while page_content != []:
1109 results = list(filter(lambda x: str(x.id) == str(comment_id), page_content))
1110 if results == []:
1111 results = list(
1112 filter(
1113 lambda x: str(x.id) == str(comment_id),
1114 [item for x in page_content for item in x.cached_replies],
1115 )
1116 )
1117 if results != []:
1118 return results[0]
1119 else:
1120 return results[0]
1121 page += 1
1122 page_content = self.comments(page=page)
1123 raise exceptions.CommentNotFound()
1124
1125 def message_events(self):
1126 return message_events.MessageEvents(self)

Callers 3

parent_commentMethod · 0.45
repliesMethod · 0.45
target_commentMethod · 0.45

Calls 2

commentsMethod · 0.95
filterFunction · 0.85

Tested by

no test coverage detected