Copyright | (c) 2021 Rory Tyler Hayford |
---|---|
License | BSD-3-Clause |
Maintainer | rory.hayford@protonmail.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- getSubmissions :: (MonadReddit m, Foldable t) => ItemOpts Submission -> t SubmissionID -> m (Seq Submission)
- getSubmission :: MonadReddit m => SubmissionID -> m Submission
- getSubmissionByURL :: MonadReddit m => URL -> m Submission
- getSubmissionsByDomain :: MonadReddit m => Domain -> Paginator SubmissionID Submission -> m (Listing SubmissionID Submission)
- getBest :: MonadReddit m => Paginator SubmissionID Submission -> m (Listing SubmissionID Submission)
- getChildComments :: MonadReddit m => SubmissionID -> m (Seq ChildComment)
- getDuplicateSubmissions :: MonadReddit m => SubmissionID -> m (Seq Submission)
- saveSubmission :: MonadReddit m => SubmissionID -> m ()
- unsaveSubmission :: MonadReddit m => SubmissionID -> m ()
- hideSubmissions :: (MonadReddit m, Foldable t) => t SubmissionID -> m ()
- hideSubmission :: MonadReddit m => SubmissionID -> m ()
- unhideSubmissions :: (MonadReddit m, Foldable t) => t SubmissionID -> m ()
- unhideSubmission :: MonadReddit m => SubmissionID -> m ()
- deleteSubmission :: MonadReddit m => SubmissionID -> m ()
- editSubmission :: MonadReddit m => SubmissionID -> Body -> m Submission
- replyToSubmission :: MonadReddit m => SubmissionID -> Body -> m Comment
- submitSelfPost :: MonadReddit m => SubredditName -> Title -> Body -> m Submission
- submitWithInlineMedia :: (MonadReddit m, Traversable t) => Maybe Char -> Body -> t InlineMedia -> SubmissionOptions -> m Submission
- submitLink :: MonadReddit m => SubredditName -> Title -> URL -> m Submission
- submitImage :: MonadReddit m => FilePath -> SubmissionOptions -> m ()
- submitVideo :: MonadReddit m => Bool -> FilePath -> Maybe FilePath -> SubmissionOptions -> m ()
- submitPoll :: (MonadReddit m, Foldable t) => Poll t -> SubmissionOptions -> m ()
- submitGallery :: (MonadReddit m, Traversable t) => t GalleryImage -> SubmissionOptions -> m ()
- submit :: MonadReddit m => NewSubmission -> m Submission
- crosspost :: MonadReddit m => SubmissionID -> CrosspostOptions -> m Submission
- setSubmissionReplies :: MonadReddit m => Bool -> SubmissionID -> m ()
- getSubmissionFlairChoices :: MonadReddit m => SubredditName -> SubmissionID -> m (Seq FlairChoice)
- selectSubmissionFlair :: MonadReddit m => FlairSelection -> SubmissionID -> m ()
- search :: MonadReddit m => Search -> Paginator ResultID Submission -> m (Listing ResultID Submission)
- upvoteSubmission :: MonadReddit m => SubmissionID -> m ()
- downvoteSubmission :: MonadReddit m => SubmissionID -> m ()
- unvoteSubmission :: MonadReddit m => SubmissionID -> m ()
- reportSubmission :: MonadReddit m => Report -> SubmissionID -> m ()
- unmarkNSFW :: MonadReddit m => SubmissionID -> m ()
- markNSFW :: MonadReddit m => SubmissionID -> m ()
- setOC :: MonadReddit m => SubredditName -> SubmissionID -> m ()
- unsetOC :: MonadReddit m => SubredditName -> SubmissionID -> m ()
- setSpoiler :: MonadReddit m => SubmissionID -> m ()
- unsetSpoiler :: MonadReddit m => SubmissionID -> m ()
- newtype ResultID = ResultID SubmissionID
- data SearchSyntax
- data SearchCategory
- data SearchSort
- = ByRelevance
- | ByNew
- | ByHot
- | ByTop
- | ByComments
- data SearchOpts = SearchOpts SearchSort Time (Maybe SearchCategory)
- data Search = Search Text (Maybe SubredditName) (Maybe SearchSyntax)
- data PostedSubmission
- data Fancypants
- data InlineMediaType
- data InlineMedia = InlineMedia InlineMediaType FilePath Text (Maybe Body)
- data GalleryImage = GalleryImage FilePath (Maybe Body) (Maybe URL)
- data Poll t = Poll (t Text) Word (Maybe Body)
- data CrosspostOptions = CrosspostOptions SubredditName Title Bool Bool Bool (Maybe FlairID) (Maybe FlairText)
- data S3UploadLease = S3UploadLease URL (HashMap Text Text) Text URL UploadURL
- data NewSubmission
- data SubmissionOptions = SubmissionOptions Title SubredditName Bool Bool Bool Bool (Maybe CollectionID) (Maybe FlairID) (Maybe FlairText)
- data NewCollection = NewCollection Title Body SubredditID (Maybe CollectionLayout)
- type CollectionID = Text
- data CollectionLayout
- data Collection = Collection CollectionID Username Title SubredditID Body URL UTCTime UTCTime (Seq SubmissionID) (Seq Submission) (Maybe CollectionLayout)
- type PollOptionID = Text
- data PollOption = PollOption PollOptionID Body Integer
- data PollData = PollData (Seq PollOption) Integer UTCTime (Maybe PollOptionID)
- data SubmissionContent
- data Submission = Submission SubmissionID Title Username SubmissionContent SubredditName UTCTime (Maybe UTCTime) URL Domain Integer Integer (Maybe Integer) (Maybe Integer) (Maybe Rational) Integer (Seq ItemReport) (Seq ItemReport) (Maybe Integer) (Maybe Distinction) Bool Bool Bool Bool Bool (Maybe PollData)
- newtype SubmissionID = SubmissionID Text
- mkSubmissionOptions :: SubredditName -> Title -> SubmissionOptions
- mkCrosspostOptions :: SubredditName -> Title -> CrosspostOptions
- mkPoll :: (Foldable t, MonadThrow m) => t Text -> Word -> m (Poll t)
- mkGalleryImage :: FilePath -> GalleryImage
- writeInlineMedia :: InlineMediaUpload -> Body
- mkSearch :: Text -> Search
- mkSearchCategory :: MonadThrow m => Text -> m SearchCategory
Reading submissions
getSubmissions :: (MonadReddit m, Foldable t) => ItemOpts Submission -> t SubmissionID -> m (Seq Submission) Source #
Get a information on Submission
s given a container of SubmissionID
s
getSubmission :: MonadReddit m => SubmissionID -> m Submission Source #
Get information on a single submission. Throws an exception if no such
Submission
exists
getSubmissionByURL :: MonadReddit m => URL -> m Submission Source #
Get a Submission
from a URL pointing to it, in one of the following forms:
- http{s}://redd.it/<ID>
- http{s}://{www.}reddit.com/comments/<ID>/
- http{s}://{www.}reddit.com/r/<SUBREDDIT>/comments/<ID>/{NAME}
- http{s}://{www.}reddit.com/gallery/<ID>
getSubmissionsByDomain :: MonadReddit m => Domain -> Paginator SubmissionID Submission -> m (Listing SubmissionID Submission) Source #
Get a Listing
of submissions based on their domain
getBest :: MonadReddit m => Paginator SubmissionID Submission -> m (Listing SubmissionID Submission) Source #
Get the "best" Submission
s from the frontpage
getChildComments :: MonadReddit m => SubmissionID -> m (Seq ChildComment) Source #
Get a submission's ChildComment
s
getDuplicateSubmissions :: MonadReddit m => SubmissionID -> m (Seq Submission) Source #
Get a Listing
of Submission
s that are marked as duplicates of the given
submission
saveSubmission :: MonadReddit m => SubmissionID -> m () Source #
Save a submission
unsaveSubmission :: MonadReddit m => SubmissionID -> m () Source #
Unsave a submission
hideSubmissions :: (MonadReddit m, Foldable t) => t SubmissionID -> m () Source #
Hide the submissions corresponding to a container of SubmissionID
s. The
submissions will no longer appear in your default view of submissions on the
subdreddit
hideSubmission :: MonadReddit m => SubmissionID -> m () Source #
Hide a single submission
unhideSubmissions :: (MonadReddit m, Foldable t) => t SubmissionID -> m () Source #
Unhide the submissions corresponding to a container of SubmissionID
s,
returning them to your default view
unhideSubmission :: MonadReddit m => SubmissionID -> m () Source #
Unhide a single submission
Creating, editing, and deleting
deleteSubmission :: MonadReddit m => SubmissionID -> m () Source #
Delete a submission that the currently authenticated user has authored
editSubmission :: MonadReddit m => SubmissionID -> Body -> m Submission Source #
Edit a submission, receving an updated Submission
in response
replyToSubmission :: MonadReddit m => SubmissionID -> Body -> m Comment Source #
Leave a reply on a submission, returning the new Comment
that has been
created
submitSelfPost :: MonadReddit m => SubredditName -> Title -> Body -> m Submission Source #
Submit a new self-post (with no inline media)
submitWithInlineMedia Source #
:: (MonadReddit m, Traversable t) | |
=> Maybe Char | Delimiter for the placeholders in the body, defaults to |
-> Body | Should contain the placeholders, as described above |
-> t InlineMedia | The |
-> SubmissionOptions | |
-> m Submission |
Submit a new self-post with inline media. The Body
must be markdown-
formatted text containing placeholders. Each placeholder must correspond to
exactly one of the InlineMedia
s' key
field. For example, given the
following:
>>>
gif = InlineMedia InlineGIF "/path/to/a.gif" "gif" Nothing
>>>
vid = InlineMedia InlineVideo "/path/to/a.mp4" "vid" (Just "my video")
>>>
body = "Body with an inline gif #gif# and video #vid#"
>>>
submitWithInlineMedia Nothing body [gif, vid] myOptions
Will automatically produce (internally) the following markdown body for the submission, after uploading the media to Reddit's servers:
Body with an inline gif ![gif](j2k2xmfl3 "") and video ![video](ccdoe02xu "my video")
submitLink :: MonadReddit m => SubredditName -> Title -> URL -> m Submission Source #
Submit a new link post
:: MonadReddit m | |
=> FilePath | Must be a valid image file |
-> SubmissionOptions | |
-> m () |
Post an image submission to the subreddit, uploading the image file. This action does not currently return the posted submission upon success
:: MonadReddit m | |
=> Bool | If |
-> FilePath | Must be a valid video file |
-> Maybe FilePath | Must be a valid image file, for the video thumbnail. If
|
-> SubmissionOptions | |
-> m () |
Post an image submission to the subreddit, uploading the image file. This action does not currently return the posted submission upon success
submitPoll :: (MonadReddit m, Foldable t) => Poll t -> SubmissionOptions -> m () Source #
submitGallery :: (MonadReddit m, Traversable t) => t GalleryImage -> SubmissionOptions -> m () Source #
Post a gallery to the subreddit, given a container of GalleryImage
s. See
mkGalleryImage
to create the images with default values. This action also
ensures that the image container has at least two elements
submit :: MonadReddit m => NewSubmission -> m Submission Source #
Submit a new submission, returning the Submission
that has been created.
This action allows for more fine-grained control over submission options. You
can use mkSubmissionOptions
for defaults and update it as needed. See also
submitImage
, submitPoll
, and submitGallery
, which should be used when
submitting anything beyond a self-text or link post
crosspost :: MonadReddit m => SubmissionID -> CrosspostOptions -> m Submission Source #
Crosspost an existing submission. You must be a subscriber of the subreddit
you are posting into. See also mkCrosspostOptions
setSubmissionReplies :: MonadReddit m => Bool -> SubmissionID -> m () Source #
Enable/disable inbox replies for a submission
Submission flair
getSubmissionFlairChoices :: MonadReddit m => SubredditName -> SubmissionID -> m (Seq FlairChoice) Source #
Get the available FlairChoice
s for a particular submission on the given
subreddit
selectSubmissionFlair :: MonadReddit m => FlairSelection -> SubmissionID -> m () Source #
Select a FlairChoice
for a submission.
Searching
search :: MonadReddit m => Search -> Paginator ResultID Submission -> m (Listing ResultID Submission) Source #
Search
through Reddit Submission
s, either side-wide or constrained to
one subreddit. See mkSearch
to create the initial Search
Voting
Note: According to Reddit's API rules:
votes must be cast by humans. That is, API clients proxying a human's action one-for-one are OK, but bots deciding how to vote on content or amplifying a human's vote are not. See the reddit rules for more details on what constitutes vote cheating.
upvoteSubmission :: MonadReddit m => SubmissionID -> m () Source #
Upvote a submission
downvoteSubmission :: MonadReddit m => SubmissionID -> m () Source #
Downvote a submission
unvoteSubmission :: MonadReddit m => SubmissionID -> m () Source #
Remove an existing vote on a submission
reportSubmission :: MonadReddit m => Report -> SubmissionID -> m () Source #
Report a submission to the subreddit's mods
Misc
unmarkNSFW :: MonadReddit m => SubmissionID -> m () Source #
Unmark a submission NSFW. The submission author can use this as well as the subreddit moderators
markNSFW :: MonadReddit m => SubmissionID -> m () Source #
Mark a submission NSFW. The submission author can use this as well as the subreddit moderators
setOC :: MonadReddit m => SubredditName -> SubmissionID -> m () Source #
Mark a submission as original content. In order for normal users to use this feature in addition to mods, the beta "Original Content" feature must be enabled in the subreddit settings
unsetOC :: MonadReddit m => SubredditName -> SubmissionID -> m () Source #
Unmark a submission as original content. In order for normal users to use this feature in addition to mods, the beta "Original Content" feature must be enabled in the subreddit settings
setSpoiler :: MonadReddit m => SubmissionID -> m () Source #
Mark the submission as containing spoilers
unsetSpoiler :: MonadReddit m => SubmissionID -> m () Source #
Unmark the submission as containing spoilers
Types
A wrapper around SubmissionID
s that allows Listing ResultID a
to be
distinguished from Listing SubmissionID a
Instances
Show ResultID Source # | |
Generic ResultID Source # | |
FromJSON ResultID Source # | |
Thing ResultID Source # | |
type Rep ResultID Source # | |
Defined in Network.Reddit.Types.Submission type Rep ResultID = D1 ('MetaData "ResultID" "Network.Reddit.Types.Submission" "heddit-0.0.1-76ROQ5tOAm3CpLSaFw8ccb" 'True) (C1 ('MetaCons "ResultID" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SubmissionID))) |
data SearchSyntax Source #
The syntax to use in the Search
Instances
data SearchCategory Source #
The category for the Search
Instances
Eq SearchCategory Source # | |
Defined in Network.Reddit.Types.Submission (==) :: SearchCategory -> SearchCategory -> Bool # (/=) :: SearchCategory -> SearchCategory -> Bool # | |
Show SearchCategory Source # | |
Defined in Network.Reddit.Types.Submission showsPrec :: Int -> SearchCategory -> ShowS # show :: SearchCategory -> String # showList :: [SearchCategory] -> ShowS # | |
Generic SearchCategory Source # | |
Defined in Network.Reddit.Types.Submission type Rep SearchCategory :: Type -> Type # from :: SearchCategory -> Rep SearchCategory x # to :: Rep SearchCategory x -> SearchCategory # | |
type Rep SearchCategory Source # | |
Defined in Network.Reddit.Types.Submission type Rep SearchCategory = D1 ('MetaData "SearchCategory" "Network.Reddit.Types.Submission" "heddit-0.0.1-76ROQ5tOAm3CpLSaFw8ccb" 'True) (C1 ('MetaCons "SearchCategory" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) |
data SearchSort Source #
The sort order for Search
es
Instances
data SearchOpts Source #
Options for paginating and filtering Search
es
Instances
The text to search, along with an optional SubredditName
Instances
data PostedSubmission Source #
Wrapper for getting the URL from the JSON object that is returned when posting a new submissions
Instances
Show PostedSubmission Source # | |
Defined in Network.Reddit.Types.Submission showsPrec :: Int -> PostedSubmission -> ShowS # show :: PostedSubmission -> String # showList :: [PostedSubmission] -> ShowS # | |
Generic PostedSubmission Source # | |
Defined in Network.Reddit.Types.Submission type Rep PostedSubmission :: Type -> Type # from :: PostedSubmission -> Rep PostedSubmission x # to :: Rep PostedSubmission x -> PostedSubmission # | |
FromJSON PostedSubmission Source # | |
Defined in Network.Reddit.Types.Submission parseJSON :: Value -> Parser PostedSubmission # parseJSONList :: Value -> Parser [PostedSubmission] # | |
type Rep PostedSubmission Source # | |
Defined in Network.Reddit.Types.Submission type Rep PostedSubmission = D1 ('MetaData "PostedSubmission" "Network.Reddit.Types.Submission" "heddit-0.0.1-76ROQ5tOAm3CpLSaFw8ccb" 'True) (C1 ('MetaCons "PostedSubmission" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 URL))) |
data Fancypants Source #
Represents richtext JSON object. This should be generated through an API endpoint
Instances
data InlineMediaType Source #
The type of inline media
Instances
data InlineMedia Source #
A piece of inline media that can be added to a self-text post
Instances
data GalleryImage Source #
A single image in a gallery submission
Instances
A Reddit poll. See mkPoll
to create a new one satisfying Reddit
constraints on poll options and duration
Instances
Eq (t Text) => Eq (Poll t) Source # | |
Show (t Text) => Show (Poll t) Source # | |
Generic (Poll t) Source # | |
type Rep (Poll t) Source # | |
Defined in Network.Reddit.Types.Submission type Rep (Poll t) = D1 ('MetaData "Poll" "Network.Reddit.Types.Submission" "heddit-0.0.1-76ROQ5tOAm3CpLSaFw8ccb" 'False) (C1 ('MetaCons "Poll" 'PrefixI 'True) (S1 ('MetaSel ('Just "options") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (t Text)) :*: (S1 ('MetaSel ('Just "duration") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Word) :*: S1 ('MetaSel ('Just "selftext") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe Body))))) |
data CrosspostOptions Source #
Options for crossposting a submission
Instances
data S3UploadLease Source #
Used to upload style assets and images to Reddit's servers when submitting content
Instances
data NewSubmission Source #
The type of SubmissionOptions
to submit to Reddit. In general, this
should not be used directly. See instead the various submit
actions
in Network.Reddit.Submission
SelfPost Body SubmissionOptions | |
WithInlineMedia Fancypants SubmissionOptions | The body should be generated using |
Link URL SubmissionOptions | |
ImagePost UploadURL SubmissionOptions | Please see |
VideoPost UploadURL UploadURL Bool SubmissionOptions | See the note for |
Instances
data SubmissionOptions Source #
Components to create a new submission
SubmissionOptions Title SubredditName Bool Bool Bool Bool (Maybe CollectionID) (Maybe FlairID) (Maybe FlairText) |
Instances
data NewCollection Source #
Data to create a new Collection
as a moderator action
Instances
type CollectionID = Text Source #
A UUID identifier for a Collection
data CollectionLayout Source #
The layout of the Collection
on the redesigned site
Instances
data Collection Source #
Represents a Reddit collection
Collection CollectionID Username Title SubredditID Body URL UTCTime UTCTime (Seq SubmissionID) (Seq Submission) (Maybe CollectionLayout) |
Instances
type PollOptionID = Text Source #
Identifier for a PollOption
data PollOption Source #
Single option in existing PollData
Instances
Data from an existing submission containing a poll. See Poll
for
submitting a new post with a poll
Instances
Eq PollData Source # | |
Show PollData Source # | |
Generic PollData Source # | |
FromJSON PollData Source # | |
type Rep PollData Source # | |
Defined in Network.Reddit.Types.Submission type Rep PollData = D1 ('MetaData "PollData" "Network.Reddit.Types.Submission" "heddit-0.0.1-76ROQ5tOAm3CpLSaFw8ccb" 'False) (C1 ('MetaCons "PollData" 'PrefixI 'True) ((S1 ('MetaSel ('Just "options") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Seq PollOption)) :*: S1 ('MetaSel ('Just "totalVoteCount") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Integer)) :*: (S1 ('MetaSel ('Just "votingEnds") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 UTCTime) :*: S1 ('MetaSel ('Just "userSelection") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 (Maybe PollOptionID))))) |
data SubmissionContent Source #
The contents of the Submission
. Can be a self-post with a plaintext and
HTML body, an external link, or entirely empty
Instances
data Submission Source #
A submitted self-text post or link
Instances
newtype SubmissionID Source #
Unique, site-wide ID for a Submission
Instances
mkSubmissionOptions :: SubredditName -> Title -> SubmissionOptions Source #
Create a SubmissionOptions
with default values for most fields
mkCrosspostOptions :: SubredditName -> Title -> CrosspostOptions Source #
CrosspostOptions
with default values for most fields
mkPoll :: (Foldable t, MonadThrow m) => t Text -> Word -> m (Poll t) Source #
Create a new Poll
, validating the following constraints:
* The duration
is between 1 and 7
* The number of options
is between 2 and 6
mkGalleryImage :: FilePath -> GalleryImage Source #
Create a GalleryImage
with default values for the caption
and
outboundURL
fields
writeInlineMedia :: InlineMediaUpload -> Body Source #
Write an InlineMediaUpload
in markdown format
mkSearch :: Text -> Search Source #
Create a new Search
by providing the query, with defaults for the other
fields
mkSearchCategory :: MonadThrow m => Text -> m SearchCategory Source #
Create a SearchCategory
from Text
, the length of which must not exceed
5 characters