Reddit.NET  1.5
Reddit.NET is a .NET Standard library that provides easy access to the Reddit API with virtually no boilerplate code required.
Reddit.Controllers.PrivateMessages Class Reference

Controller class for private messages. More...

Inheritance diagram for Reddit.Controllers.PrivateMessages:
Reddit.Controllers.Internal.Monitors Reddit.Controllers.BaseController Reddit.Controllers.Internal.Validators

Public Member Functions

 PrivateMessages (Dispatch dispatch, List< Message > inbox=null, List< Message > unread=null, List< Message > sent=null)
 Create a new instance of the private messages controller. More...
 
List< MessageGetMessages (string where, bool mark=true, int limit=25, string after="", string before="", string show="all", bool srDetail=false, bool includeCategories=false, int count=0, string mid="")
 Retrieve private messages for the current user. More...
 
List< MessageGetMessages (string where, PrivateMessagesGetMessagesInput privateMessagesGetMessagesInput)
 Retrieve private messages for the current user. More...
 
List< MessageGetMessagesInbox (bool mark=true, int limit=25, string after="", string before="", string show="all", bool srDetail=false, bool includeCategories=false, int count=0, string mid="")
 Retrieve private inbox messages for the current user. More...
 
List< MessageGetMessagesUnread (bool mark=true, int limit=25, string after="", string before="", string show="all", bool srDetail=false, bool includeCategories=false, int count=0, string mid="")
 Retrieve private unread messages for the current user. More...
 
List< MessageGetMessagesSent (bool mark=true, int limit=25, string after="", string before="", string show="all", bool srDetail=false, bool includeCategories=false, int count=0, string mid="")
 Retrieve private sent messages for the current user. More...
 
void MarkAllRead (string filterTypes="")
 Queue up marking all messages for a user as read. This may take some time, and returns 202 to acknowledge acceptance of the request. More...
 
async Task MarkAllReadAsync (string filterTypes="")
 Asynchronously queue up marking all messages for a user as read. This may take some time, and returns 202 to acknowledge acceptance of the request. More...
 
void CollapseMessage (string ids)
 Collapse a message. More...
 
async Task CollapseMessageAsync (string ids)
 Collapse a message asynchronously. More...
 
void DeleteMessage (string id)
 Delete messages from the recipient's view of their inbox. More...
 
async Task DeleteMessageAsync (string id)
 Delete messages from the recipient's view of their inbox asynchronously. More...
 
void ReadMessage (string ids)
 Mark a message as read. More...
 
async Task ReadMessageAsync (string ids)
 Mark a message as read asynchronously. More...
 
void UncollapseMessage (string ids)
 Uncollapse a message. More...
 
async Task UncollapseMessageAsync (string ids)
 Uncollapse a message asynchronously. More...
 
void UnreadMessage (string ids)
 Mark a message as unread. More...
 
async Task UnreadMessageAsync (string ids)
 Mark a message as unread asynchronously. More...
 
void Compose (string to, string subject, string text, string fromSr="", string gRecaptchaResponse="")
 Send a private message. More...
 
async Task ComposeAsync (string to, string subject, string text, string fromSr="", string gRecaptchaResponse="")
 Send a private message asynchronously. More...
 
void Compose (PrivateMessagesComposeInput privateMessagesComposeInput, string gRecaptchaResponse="")
 Send a private message. More...
 
async Task ComposeAsync (PrivateMessagesComposeInput privateMessagesComposeInput, string gRecaptchaResponse="")
 Send a private message asynchronously. More...
 
MessageContainer Reply (LinksAndCommentsThingInput linksAndCommentsThingInput)
 Reply to a private message. More...
 
async Task< MessageContainerReplyAsync (LinksAndCommentsThingInput linksAndCommentsThingInput)
 Reply to a private message asynchronously. More...
 
bool MonitorInbox (int? monitoringDelayMs=null, int? monitoringBaseDelayMs=null, List< MonitoringSchedule > schedule=null, bool? breakOnFailure=null, DateTime? monitoringExpiration=null, bool useCache=true)
 Monitor inbox messages. More...
 
bool MonitorUnread (int? monitoringDelayMs=null, int? monitoringBaseDelayMs=null, List< MonitoringSchedule > schedule=null, bool? breakOnFailure=null, DateTime? monitoringExpiration=null, bool useCache=true)
 Monitor unread messages. More...
 
bool MonitorSent (int? monitoringDelayMs=null, int? monitoringBaseDelayMs=null, List< MonitoringSchedule > schedule=null, bool? breakOnFailure=null, DateTime? monitoringExpiration=null, bool useCache=true)
 Monitor sent messages. More...
 
bool PrivateMessagesInboxIsMonitored ()
 Whether inbox is being monitored. More...
 
bool PrivateMessagesUnreadIsMonitored ()
 Whether unread is being monitored. More...
 
bool PrivateMessagesSentIsMonitored ()
 Whether sent is being monitored. More...
 
- Public Member Functions inherited from Reddit.Controllers.Internal.Monitors
 Monitors ()
 
void Wait (int ms)
 
bool IsMonitored (string key, string subKey)
 
bool IsScheduled ()
 
void WaitOrDie (string key, int timeout=60)
 
void WaitOrDie (Thread thread, int timeout=60)
 
void KillAllMonitoringThreads ()
 
- Public Member Functions inherited from Reddit.Controllers.BaseController
 BaseController ()
 Create a new Controller instance. More...
 
- Public Member Functions inherited from Reddit.Controllers.Internal.Validators
Exception BuildException (Exception ex, List< List< string >> errors)
 
dynamic Validate (dynamic obj)
 
GenericContainer Validate (GenericContainer genericContainer)
 
Generic Validate (Generic generic)
 
DynamicShortListingContainer Validate (DynamicShortListingContainer dynamicShortListingContainer)
 
DynamicShortListingData Validate (DynamicShortListingData dynamicShortListingData)
 
ImageUploadResult Validate (ImageUploadResult imageUploadResult)
 
LiveUpdateEventContainer Validate (LiveUpdateEventContainer liveUpdateEventContainer)
 
LiveThreadCreateResultContainer Validate (LiveThreadCreateResultContainer liveThreadCreateResultContainer)
 
LiveUpdateContainer Validate (LiveUpdateContainer liveUpdateContainer, int? minChildren=null)
 
SubredditSettingsContainer Validate (SubredditSettingsContainer subredditSettingsContainer)
 
SubredditSettings Validate (SubredditSettings subredditSettings)
 
List< ActionResultValidate (List< ActionResult > actionResults)
 
ActionResult Validate (ActionResult actionResult)
 
FlairListResultContainer Validate (FlairListResultContainer flairListResultContainer)
 
Flair Validate (Flair flair)
 
FlairV2 Validate (FlairV2 flairV2)
 
ModActionContainer Validate (ModActionContainer modActionContainer)
 
ModActionData Validate (ModActionData modActionData)
 
WikiPageRevisionContainer Validate (WikiPageRevisionContainer wikiPageRevisionContainer)
 
WikiPageRevisionData Validate (WikiPageRevisionData wikiPageRevisionData)
 
WikiPageSettingsContainer Validate (WikiPageSettingsContainer wikiPageSettingsContainer)
 
WikiPageSettings Validate (WikiPageSettings wikiPageSettings)
 
List< UserPrefsContainerValidate (List< UserPrefsContainer > userPrefsContainers)
 
UserPrefsContainer Validate (UserPrefsContainer userPrefsContainer)
 
UserPrefsData Validate (UserPrefsData userPrefsData)
 
PostResultShortContainer Validate (PostResultShortContainer postResultShortContainer)
 
PostResultShort Validate (PostResultShort postResultShort)
 
PostResultContainer Validate (PostResultContainer postResultContainer)
 
PostResult Validate (PostResult postResult)
 
JQueryReturn Validate (JQueryReturn jQueryReturn)
 
List<(PostContainer, CommentContainer)> Validate (List<(PostContainer, CommentContainer)> ps)
 
CommentResultContainer Validate (CommentResultContainer commentResultContainer)
 
SubredditContainer Validate (SubredditContainer subredditContainer)
 

Protected Member Functions

virtual void OnInboxUpdated (MessagesUpdateEventArgs e)
 Invoke monitoring event for inbox. More...
 
virtual void OnUnreadUpdated (MessagesUpdateEventArgs e)
 Invoke monitoring event for unread. More...
 
virtual void OnSentUpdated (MessagesUpdateEventArgs e)
 Invoke monitoring event for sent. More...
 
void TriggerUpdate (MessagesUpdateEventArgs args, string type)
 Invoke the appropriate event for the given type. More...
 
override Thread CreateMonitoringThread (string key, string subKey, int startDelayMs=0, int? monitoringDelayMs=null)
 Creates a new monitoring thread. More...
 
- Protected Member Functions inherited from Reddit.Controllers.Internal.Monitors
bool Monitor (string key, Thread thread, string subKey)
 
void RebuildThreads (string subKey)
 
void LaunchThreadIfNotNull (string key, Thread thread)
 
void KillThread (Thread thread)
 
void KillThread (string key)
 
void ResetThreads (List< string > oldThreads)
 
- Protected Member Functions inherited from Reddit.Controllers.Internal.Validators
void CheckErrors (List< List< string >> errors)
 
void CheckErrors (List< string > errors)
 
void CheckNull (object res, string msg="Reddit API returned null response.")
 

Properties

List< Message >? Inbox [get]
 List of inbox messages. More...
 
List< Message >? Unread [get]
 List of unread messages. More...
 
List< Message >? Sent [get]
 List of sent messages. More...
 
- Properties inherited from Reddit.Controllers.Internal.Monitors
IDictionary< string, HashSet< string > > MonitoringCache [get, set]
 An optional cache for preventing the same post from appearing multiple times during monitoring. See: https://github.com/sirkris/Reddit.NET/issues/117#issuecomment-759501039 More...
 
- Properties inherited from Reddit.Controllers.BaseController
Lists Lists [get, set]
 List-handling. More...
 

Events

EventHandler< MessagesUpdateEventArgsInboxUpdated
 Event handler for monitoring inbox. More...
 
EventHandler< MessagesUpdateEventArgsUnreadUpdated
 Event handler for monitoring unread. More...
 
EventHandler< MessagesUpdateEventArgsSentUpdated
 Event handler for monitoring sent. More...
 

Additional Inherited Members

- Public Attributes inherited from Reddit.Controllers.Internal.Monitors
int MonitoringWaitDelayMS = 1500
 
- Protected Attributes inherited from Reddit.Controllers.Internal.Monitors
volatile bool Terminate = false
 

Detailed Description

Controller class for private messages.

Constructor & Destructor Documentation

◆ PrivateMessages()

Reddit.Controllers.PrivateMessages.PrivateMessages ( Dispatch  dispatch,
List< Message inbox = null,
List< Message unread = null,
List< Message sent = null 
)

Create a new instance of the private messages controller.

Parameters
dispatch
inbox
unread
sent

Member Function Documentation

◆ CollapseMessage()

void Reddit.Controllers.PrivateMessages.CollapseMessage ( string  ids)

Collapse a message.

Parameters
idsA comma-separated list of thing fullnames

◆ CollapseMessageAsync()

async Task Reddit.Controllers.PrivateMessages.CollapseMessageAsync ( string  ids)

Collapse a message asynchronously.

Parameters
idsA comma-separated list of thing fullnames

◆ Compose() [1/2]

void Reddit.Controllers.PrivateMessages.Compose ( PrivateMessagesComposeInput  privateMessagesComposeInput,
string  gRecaptchaResponse = "" 
)

Send a private message.

Parameters
privateMessagesComposeInputA valid PrivateMessagesComposeInput instance
gRecaptchaResponse

◆ Compose() [2/2]

void Reddit.Controllers.PrivateMessages.Compose ( string  to,
string  subject,
string  text,
string  fromSr = "",
string  gRecaptchaResponse = "" 
)

Send a private message.

Parameters
tothe name of an existing user
subjecta string no longer than 100 characters
textraw markdown text
fromSrsubreddit name
gRecaptchaResponse

◆ ComposeAsync() [1/2]

async Task Reddit.Controllers.PrivateMessages.ComposeAsync ( PrivateMessagesComposeInput  privateMessagesComposeInput,
string  gRecaptchaResponse = "" 
)

Send a private message asynchronously.

Parameters
privateMessagesComposeInputA valid PrivateMessagesComposeInput instance
gRecaptchaResponse

◆ ComposeAsync() [2/2]

async Task Reddit.Controllers.PrivateMessages.ComposeAsync ( string  to,
string  subject,
string  text,
string  fromSr = "",
string  gRecaptchaResponse = "" 
)

Send a private message asynchronously.

Parameters
tothe name of an existing user
subjecta string no longer than 100 characters
textraw markdown text
fromSrsubreddit name
gRecaptchaResponse

◆ CreateMonitoringThread()

override Thread Reddit.Controllers.PrivateMessages.CreateMonitoringThread ( string  key,
string  subKey,
int  startDelayMs = 0,
int?  monitoringDelayMs = null 
)
protectedvirtual

Creates a new monitoring thread.

Parameters
keyMonitoring key
subKeyMonitoring subKey
startDelayMsHow long to wait before starting the thread in milliseconds (default: 0)
monitoringDelayMsHow long to wait between monitoring queries; pass null to leave it auto-managed (default: null)
Returns
The newly-created monitoring thread.

Implements Reddit.Controllers.Internal.Monitors.

◆ DeleteMessage()

void Reddit.Controllers.PrivateMessages.DeleteMessage ( string  id)

Delete messages from the recipient's view of their inbox.

Parameters
idfullname of a thing

◆ DeleteMessageAsync()

async Task Reddit.Controllers.PrivateMessages.DeleteMessageAsync ( string  id)

Delete messages from the recipient's view of their inbox asynchronously.

Parameters
idfullname of a thing

◆ GetMessages() [1/2]

List<Message> Reddit.Controllers.PrivateMessages.GetMessages ( string  where,
bool  mark = true,
int  limit = 25,
string  after = "",
string  before = "",
string  show = "all",
bool  srDetail = false,
bool  includeCategories = false,
int  count = 0,
string  mid = "" 
)

Retrieve private messages for the current user.

Parameters
whereOne of (inbox, unread, sent)
markone of (true, false)
limitthe maximum number of items desired (default: 25, maximum: 100)
afterfullname of a thing
beforefullname of a thing
show(optional) the string all
srDetail(optional) expand subreddits
includeCategoriesboolean value
counta positive integer (default: 0)
mid
Returns
A list of messages.

◆ GetMessages() [2/2]

List<Message> Reddit.Controllers.PrivateMessages.GetMessages ( string  where,
PrivateMessagesGetMessagesInput  privateMessagesGetMessagesInput 
)

Retrieve private messages for the current user.

Parameters
whereOne of (inbox, unread, sent)
privateMessagesGetMessagesInputA valid PrivateMessagesGetMessagesInput instance
Returns
A list of messages.

◆ GetMessagesInbox()

List<Message> Reddit.Controllers.PrivateMessages.GetMessagesInbox ( bool  mark = true,
int  limit = 25,
string  after = "",
string  before = "",
string  show = "all",
bool  srDetail = false,
bool  includeCategories = false,
int  count = 0,
string  mid = "" 
)

Retrieve private inbox messages for the current user.

Parameters
markone of (true, false)
limitthe maximum number of items desired (default: 25, maximum: 100)
afterfullname of a thing
beforefullname of a thing
show(optional) the string all
srDetail(optional) expand subreddits
includeCategoriesboolean value
counta positive integer (default: 0)
mid
Returns
A list of messages.

◆ GetMessagesSent()

List<Message> Reddit.Controllers.PrivateMessages.GetMessagesSent ( bool  mark = true,
int  limit = 25,
string  after = "",
string  before = "",
string  show = "all",
bool  srDetail = false,
bool  includeCategories = false,
int  count = 0,
string  mid = "" 
)

Retrieve private sent messages for the current user.

Parameters
markone of (true, false)
limitthe maximum number of items desired (default: 25, maximum: 100)
afterfullname of a thing
beforefullname of a thing
show(optional) the string all
srDetail(optional) expand subreddits
includeCategoriesboolean value
counta positive integer (default: 0)
mid
Returns
A list of messages.

◆ GetMessagesUnread()

List<Message> Reddit.Controllers.PrivateMessages.GetMessagesUnread ( bool  mark = true,
int  limit = 25,
string  after = "",
string  before = "",
string  show = "all",
bool  srDetail = false,
bool  includeCategories = false,
int  count = 0,
string  mid = "" 
)

Retrieve private unread messages for the current user.

Parameters
markone of (true, false)
limitthe maximum number of items desired (default: 25, maximum: 100)
afterfullname of a thing
beforefullname of a thing
show(optional) the string all
srDetail(optional) expand subreddits
includeCategoriesboolean value
counta positive integer (default: 0)
mid
Returns
A list of messages.

◆ MarkAllRead()

void Reddit.Controllers.PrivateMessages.MarkAllRead ( string  filterTypes = "")

Queue up marking all messages for a user as read. This may take some time, and returns 202 to acknowledge acceptance of the request.

Parameters
filterTypesA comma-separated list of items

◆ MarkAllReadAsync()

async Task Reddit.Controllers.PrivateMessages.MarkAllReadAsync ( string  filterTypes = "")

Asynchronously queue up marking all messages for a user as read. This may take some time, and returns 202 to acknowledge acceptance of the request.

Parameters
filterTypesA comma-separated list of items

◆ MonitorInbox()

bool Reddit.Controllers.PrivateMessages.MonitorInbox ( int?  monitoringDelayMs = null,
int?  monitoringBaseDelayMs = null,
List< MonitoringSchedule schedule = null,
bool?  breakOnFailure = null,
DateTime?  monitoringExpiration = null,
bool  useCache = true 
)

Monitor inbox messages.

Parameters
monitoringDelayMsThe number of milliseconds between each monitoring query; leave null to auto-manage
monitoringBaseDelayMsThe number of milliseconds between each monitoring query PER THREAD (default: 1500)
scheduleA list of one or more timeframes during which monitoring of this object will occur (default: 24/7)
breakOnFailureIf true, an exception will be thrown when a monitoring query fails; leave null to keep current setting (default: false)
monitoringExpirationIf set, monitoring will automatically stop after the specified DateTime is reached
useCacheWhether to cache the IDs of the monitoring results to prevent duplicate fires (default: true)
Returns
Whether monitoring was successfully initiated.

◆ MonitorSent()

bool Reddit.Controllers.PrivateMessages.MonitorSent ( int?  monitoringDelayMs = null,
int?  monitoringBaseDelayMs = null,
List< MonitoringSchedule schedule = null,
bool?  breakOnFailure = null,
DateTime?  monitoringExpiration = null,
bool  useCache = true 
)

Monitor sent messages.

Parameters
monitoringDelayMsThe number of milliseconds between each monitoring query; leave null to auto-manage
monitoringBaseDelayMsThe number of milliseconds between each monitoring query PER THREAD (default: 1500)
scheduleA list of one or more timeframes during which monitoring of this object will occur (default: 24/7)
breakOnFailureIf true, an exception will be thrown when a monitoring query fails; leave null to keep current setting (default: false)
monitoringExpirationIf set, monitoring will automatically stop after the specified DateTime is reached
useCacheWhether to cache the IDs of the monitoring results to prevent duplicate fires (default: true)
Returns
Whether monitoring was successfully initiated.

◆ MonitorUnread()

bool Reddit.Controllers.PrivateMessages.MonitorUnread ( int?  monitoringDelayMs = null,
int?  monitoringBaseDelayMs = null,
List< MonitoringSchedule schedule = null,
bool?  breakOnFailure = null,
DateTime?  monitoringExpiration = null,
bool  useCache = true 
)

Monitor unread messages.

Parameters
monitoringDelayMsThe number of milliseconds between each monitoring query; leave null to auto-manage
monitoringBaseDelayMsThe number of milliseconds between each monitoring query PER THREAD (default: 1500)
scheduleA list of one or more timeframes during which monitoring of this object will occur (default: 24/7)
breakOnFailureIf true, an exception will be thrown when a monitoring query fails; leave null to keep current setting (default: false)
monitoringExpirationIf set, monitoring will automatically stop after the specified DateTime is reached
useCacheWhether to cache the IDs of the monitoring results to prevent duplicate fires (default: true)
Returns
Whether monitoring was successfully initiated.

◆ OnInboxUpdated()

virtual void Reddit.Controllers.PrivateMessages.OnInboxUpdated ( MessagesUpdateEventArgs  e)
protectedvirtual

Invoke monitoring event for inbox.

Parameters
eA valid MessagesUpdateEventArgs instance

◆ OnSentUpdated()

virtual void Reddit.Controllers.PrivateMessages.OnSentUpdated ( MessagesUpdateEventArgs  e)
protectedvirtual

Invoke monitoring event for sent.

Parameters
eA valid MessagesUpdateEventArgs instance

◆ OnUnreadUpdated()

virtual void Reddit.Controllers.PrivateMessages.OnUnreadUpdated ( MessagesUpdateEventArgs  e)
protectedvirtual

Invoke monitoring event for unread.

Parameters
eA valid MessagesUpdateEventArgs instance

◆ PrivateMessagesInboxIsMonitored()

bool Reddit.Controllers.PrivateMessages.PrivateMessagesInboxIsMonitored ( )

Whether inbox is being monitored.

Returns
Whether inbox is being monitored.

◆ PrivateMessagesSentIsMonitored()

bool Reddit.Controllers.PrivateMessages.PrivateMessagesSentIsMonitored ( )

Whether sent is being monitored.

Returns
Whether sent is being monitored.

◆ PrivateMessagesUnreadIsMonitored()

bool Reddit.Controllers.PrivateMessages.PrivateMessagesUnreadIsMonitored ( )

Whether unread is being monitored.

Returns
Whether unread is being monitored.

◆ ReadMessage()

void Reddit.Controllers.PrivateMessages.ReadMessage ( string  ids)

Mark a message as read.

Parameters
idsA comma-separated list of thing fullnames

◆ ReadMessageAsync()

async Task Reddit.Controllers.PrivateMessages.ReadMessageAsync ( string  ids)

Mark a message as read asynchronously.

Parameters
idsA comma-separated list of thing fullnames

◆ Reply()

MessageContainer Reddit.Controllers.PrivateMessages.Reply ( LinksAndCommentsThingInput  linksAndCommentsThingInput)

Reply to a private message.

Parameters
linksAndCommentsThingInputA valid LinksAndCommentsThingInput instance
Returns
The created message reply.

◆ ReplyAsync()

async Task<MessageContainer> Reddit.Controllers.PrivateMessages.ReplyAsync ( LinksAndCommentsThingInput  linksAndCommentsThingInput)

Reply to a private message asynchronously.

Parameters
linksAndCommentsThingInputA valid LinksAndCommentsThingInput instance
Returns
The created message reply.

◆ TriggerUpdate()

void Reddit.Controllers.PrivateMessages.TriggerUpdate ( MessagesUpdateEventArgs  args,
string  type 
)
protected

Invoke the appropriate event for the given type.

Parameters
argsA valid MessagesUpdateEventArgs instance
typeOne of: (inbox, unread, sent)

◆ UncollapseMessage()

void Reddit.Controllers.PrivateMessages.UncollapseMessage ( string  ids)

Uncollapse a message.

Parameters
idsA comma-separated list of thing fullnames

◆ UncollapseMessageAsync()

async Task Reddit.Controllers.PrivateMessages.UncollapseMessageAsync ( string  ids)

Uncollapse a message asynchronously.

Parameters
idsA comma-separated list of thing fullnames

◆ UnreadMessage()

void Reddit.Controllers.PrivateMessages.UnreadMessage ( string  ids)

Mark a message as unread.

Parameters
idsA comma-separated list of thing fullnames

◆ UnreadMessageAsync()

async Task Reddit.Controllers.PrivateMessages.UnreadMessageAsync ( string  ids)

Mark a message as unread asynchronously.

Parameters
idsA comma-separated list of thing fullnames

Property Documentation

◆ Inbox

List<Message>? Reddit.Controllers.PrivateMessages.Inbox
get

List of inbox messages.

◆ Sent

List<Message>? Reddit.Controllers.PrivateMessages.Sent
get

List of sent messages.

◆ Unread

List<Message>? Reddit.Controllers.PrivateMessages.Unread
get

List of unread messages.

Event Documentation

◆ InboxUpdated

EventHandler<MessagesUpdateEventArgs> Reddit.Controllers.PrivateMessages.InboxUpdated

Event handler for monitoring inbox.

◆ SentUpdated

EventHandler<MessagesUpdateEventArgs> Reddit.Controllers.PrivateMessages.SentUpdated

Event handler for monitoring sent.

◆ UnreadUpdated

EventHandler<MessagesUpdateEventArgs> Reddit.Controllers.PrivateMessages.UnreadUpdated

Event handler for monitoring unread.


The documentation for this class was generated from the following file: