MCPcopy Index your code
hub / github.com/praw-dev/praw / reply

Method reply

praw/models/reddit/modmail.py:220–258  ·  view source on GitHub ↗

Reply to the conversation. :param author_hidden: When ``True``, author is hidden from non-moderators (default: ``False``). :param body: The Markdown formatted content for a message. :param internal: When ``True``, message is a private moderator note, hidden from

(self, *, author_hidden: bool = False, body: str, internal: bool = False)

Source from the content-addressed store, hash-verified

218 self._reddit.post(API_PATH["modmail_read"], data=data)
219
220 def reply(self, *, author_hidden: bool = False, body: str, internal: bool = False) -> ModmailMessage:
221 """Reply to the conversation.
222
223 :param author_hidden: When ``True``, author is hidden from non-moderators
224 (default: ``False``).
225 :param body: The Markdown formatted content for a message.
226 :param internal: When ``True``, message is a private moderator note, hidden from
227 non-moderators (default: ``False``).
228
229 :returns: A :class:`.ModmailMessage` object for the newly created message.
230
231 For example, to reply to the non-mod user while hiding your username:
232
233 .. code-block:: python
234
235 conversation = reddit.subreddit("test").modmail("2gmz")
236 conversation.reply(body="Message body", author_hidden=True)
237
238 To create a private moderator note on the conversation:
239
240 .. code-block:: python
241
242 conversation.reply(body="Message body", internal=True)
243
244 """
245 data = {
246 "body": body,
247 "isAuthorHidden": author_hidden,
248 "isInternal": internal,
249 }
250 response = self._reddit.post(API_PATH["modmail_conversation"].format(id=self.id), data=data)
251 if isinstance(response, dict):
252 # Reddit recently changed the response format, so we need to handle both in case they change it back
253 message_id = response["conversation"]["objIds"][-1]["id"]
254 message_data = response["messages"][message_id]
255 message = self._reddit._objector.objectify(data=message_data)
256 assert isinstance(message, ModmailMessage)
257 return message
258 return next(message for message in response.messages if message.id == response.obj_ids[-1]["id"])
259
260 def unarchive(self) -> None:
261 """Unarchive the conversation.

Callers 8

test_replyMethod · 0.45
test_reply__noneMethod · 0.45
test_replyMethod · 0.45
test_reply__noneMethod · 0.45
test_replyMethod · 0.45
test_reply__internalMethod · 0.45
test_replyMethod · 0.45
process_submissionFunction · 0.45

Calls 2

postMethod · 0.80
objectifyMethod · 0.45

Tested by 7

test_replyMethod · 0.36
test_reply__noneMethod · 0.36
test_replyMethod · 0.36
test_reply__noneMethod · 0.36
test_replyMethod · 0.36
test_reply__internalMethod · 0.36
test_replyMethod · 0.36