models

package
v9.0.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllReports

type AllReports struct {
	Num  int
	Mod  []ModReport
	User []UserReport
}

AllReports simply combines ModReports & UserReports

type Comment

type Comment struct {
	AuthorFlairBackgroundColor string              `json:"author_flair_background_color"`
	TotalAwardsReceived        uint                `json:"total_awards_received"`
	ApprovedAtUTC              float64             `json:"approved_at_utc"`
	Distinguished              string              `json:"distinguished"`
	ModReasonBy                string              `json:"mod_reason_by"`
	BannedBy                   json.RawMessage     `json:"banned_by"`
	AuthorFlairType            string              `json:"author_flair_type"`
	RemovalReason              string              `json:"removal_reason"`
	LinkID                     RedditID            `json:"link_id"`
	AuthorFlairTemplateID      string              `json:"author_flair_template_id"`
	Likes                      bool                `json:"likes"`
	Replies                    json.RawMessage     `json:"replies"` // is []Response, but reddit likes to fuck with us :(
	UserReports                []UserReport        `json:"user_reports"`
	Saved                      bool                `json:"saved"`
	ID                         string              `json:"id"`
	BannedAtUTC                float64             `json:"banned_at_utc"`
	ModReasonTitle             string              `json:"mod_reason_title"`
	Gilded                     uint                `json:"gilded"`
	Archived                   bool                `json:"archived"`
	NoFollow                   bool                `json:"no_follow"`
	Author                     string              `json:"author"`
	RteMode                    string              `json:"rte_mode"`
	CanModPost                 bool                `json:"can_mod_post"`
	CreatedUTC                 float64             `json:"created_utc"`
	SendReplies                bool                `json:"send_replies"`
	ParentID                   RedditID            `json:"parent_id"`
	Score                      int                 `json:"score"`
	AuthorFullname             RedditID            `json:"author_fullname"`
	ApprovedBy                 string              `json:"approved_by"`
	ModNote                    string              `json:"mod_note"`
	AllAwardings               []PostAward         `json:"all_awardings"`
	SubredditID                RedditID            `json:"subreddit_id"`
	Body                       string              `json:"body"`
	Edited                     json.RawMessage     `json:"edited"` // bool or float64
	Gildings                   map[string]int      `json:"gildings"`
	AuthorFlairCSSClass        string              `json:"author_flair_css_class"`
	Name                       RedditID            `json:"name"`
	AuthorPatreonFlair         bool                `json:"author_patreon_flair"`
	Downs                      int                 `json:"downs"`
	AuthorFlairRichtext        []map[string]string `json:"author_flair_richtext"`
	IsSubmitter                bool                `json:"is_submitter"`
	CollapsedReason            string              `json:"collapsed_reason"`
	BodyHTML                   string              `json:"body_html"`
	Stickied                   bool                `json:"stickied"`
	CanGild                    bool                `json:"can_gild"`
	Removed                    bool                `json:"removed"`
	Approved                   bool                `json:"approved"`
	AuthorFlairTextColor       string              `json:"author_flair_text_color"`
	ScoreHidden                bool                `json:"score_hidden"`
	Permalink                  string              `json:"permalink"`
	NumReports                 int                 `json:"num_reports"`
	Locked                     bool                `json:"locked"`
	Created                    float64             `json:"created"`
	Subreddit                  string              `json:"subreddit"`
	AuthorFlairText            string              `json:"author_flair_text"`
	Spam                       bool                `json:"spam"`
	Collapsed                  bool                `json:"collapsed"`
	SubredditNamePrefixed      string              `json:"subreddit_name_prefixed"`
	Controversiality           int                 `json:"controversiality"`
	IgnoreReports              bool                `json:"ignore_reports"`
	ModReports                 []ModReport         `json:"mod_reports"`
	SubredditType              string              `json:"subreddit_type"`
	Ups                        int                 `json:"ups"`
}

Comment defines a reddit comment (t1_XXXXX)

func (Comment) CreatedAt

func (c Comment) CreatedAt() time.Time

CreatedAt returns the time.Time the post was created at

func (Comment) GetApproved

func (c Comment) GetApproved() SubModAction

GetApproved returns the mod & time who approved the Comment

func (Comment) GetAuthor

func (c Comment) GetAuthor() string

GetAuthor returns the name of the Comment Author

func (Comment) GetAuthorID

func (c Comment) GetAuthorID() RedditID

GetAuthorID returns the RedditID of the Comment Author

func (Comment) GetBanned

func (c Comment) GetBanned() SubModAction

GetBanned returns the mod & time who deleted the Comment

func (Comment) GetBody

func (c Comment) GetBody() string

GetBody returns the content of the Comment in Markdown

func (Comment) GetCreated added in v0.1.7

func (c Comment) GetCreated() time.Time

GetCreated returns the creation date of the Comment

func (Comment) GetID

func (c Comment) GetID() RedditID

GetID returns the RedditID of the Comment

func (Comment) GetParentID

func (c Comment) GetParentID() RedditID

GetParentID returns the parent RedditID of the Comment

func (Comment) GetReports

func (c Comment) GetReports() AllReports

GetReports returns the reports for the Comment

func (Comment) GetScore

func (c Comment) GetScore() int

GetScore returns the current score of the Comment

func (Comment) GetSubreddit

func (c Comment) GetSubreddit() string

GetSubreddit returns the name of the Subreddit the comment was posted in

func (Comment) GetSubredditID

func (c Comment) GetSubredditID() RedditID

GetSubredditID returns the RedditID of the subreddit the comment was posted in

func (Comment) GetTitle

func (c Comment) GetTitle() string

GetTitle returns an empty string and is here to fulfull the Submission interface

func (Comment) GetURL

func (c Comment) GetURL() string

GetURL returns the link to the Comment

func (Comment) IsApproved

func (c Comment) IsApproved() bool

IsApproved tells you if the comment has been approved (only if you are mod)

func (Comment) IsAuthor

func (c Comment) IsAuthor() bool

IsAuthor tells you if the comment has been made by OP

func (Comment) IsRemoved

func (c Comment) IsRemoved() bool

IsRemoved tells you if the comment has been removed (only if you are mod)

func (Comment) IsSticky

func (c Comment) IsSticky() bool

IsSticky tells you if the comment has been stickied

type CommentActionResponse added in v0.1.8

type CommentActionResponse struct {
	JSON struct {
		Errors []string `json:"errors"`
		Data   struct {
			Things []RedditElement `json:"things"`
		}
	} `json:"json"`
}

CommentActionResponse is returned by reddit when you create a comment (new or reply)

type Image

type Image struct {
	URL    string `json:"url"`
	Width  uint   `json:"width"`
	Height uint   `json:"height"`
}

Image defines basic image properties

type Listing

type Listing struct {
	Modhash  string          `json:"modhash"`
	Dist     int             `json:"dist"`
	Children []RedditElement `json:"children"`
	After    string          `json:"after"`
	Before   string          `json:"before"`
}

Listing contains a selection of Elements. It also provides pagination via After & Before

type Me

type Me struct {
	IsEmployee              bool          `json:"is_employee"`
	SeenLayoutSwitch        bool          `json:"seen_layout_switch"`
	HasVisitedNewProfile    bool          `json:"has_visited_new_profile"`
	PrefNoProfanity         bool          `json:"pref_no_profanity"`
	HasExternalAccount      bool          `json:"has_external_account"`
	PrefGeopopular          string        `json:"pref_geopopular"`
	SeenRedesignModal       bool          `json:"seen_redesign_modal"`
	PrefShowTrending        bool          `json:"pref_show_trending"`
	Subreddit               userSubreddit `json:"subreddit"`
	IsSponsor               bool          `json:"is_sponsor"`
	GoldExpiration          float64       `json:"gold_expiration"`
	HasGoldSubscription     bool          `json:"has_gold_subscription"`
	NumFriends              uint          `json:"num_friends"`
	Features                MeFeatures    `json:"features"`
	HasAndroidSubscription  bool          `json:"has_android_subscription"`
	Verified                bool          `json:"verified"`
	NewModmailExists        bool          `json:"new_modmail_exists"`
	PrefAutoplay            bool          `json:"pref_autoplay"`
	Coins                   uint          `json:"coins"`
	HasPaypalSubscription   bool          `json:"has_paypal_subscription"`
	HasSubscribedToPremium  bool          `json:"has_subscribed_to_premium"`
	ID                      string        `json:"id"`
	HasStripeSubscription   bool          `json:"has_stripe_subscription"`
	SeenPremiumAdblockModal bool          `json:"seen_premium_adblock_modal"`
	CanCreateSubreddit      bool          `json:"can_create_subreddit"`
	Over18                  bool          `json:"over_18"`
	IsGold                  bool          `json:"is_gold"`
	IsMod                   bool          `json:"is_mod"`
	SuspensionExpirationUTC float64       `json:"suspension_expiration_utc"`
	HasVerifiedEmail        bool          `json:"has_verified_email"`
	IsSuspended             bool          `json:"is_suspended"`
	PrefVideoAutoplay       bool          `json:"pref_video_autoplay"`
	InChat                  bool          `json:"in_chat"`
	InRedesignBeta          bool          `json:"in_redesign_beta"`
	IconImg                 string        `json:"icon_img"`
	HasModMail              bool          `json:"has_mod_mail"`
	PrefNightmode           bool          `json:"pref_nightmode"`
	OauthClientID           string        `json:"oauth_client_id"`
	HideFromRobots          bool          `json:"hide_from_robots"`
	LinkKarma               int           `json:"link_karma"`
	ForcePasswordReset      bool          `json:"force_password_reset"`
	InboxCount              uint          `json:"inbox_count"`
	PrefTopKarmaSubreddits  bool          `json:"pref_top_karma_subreddits"`
	HasMail                 bool          `json:"has_mail"`
	PrefShowSnoovatar       bool          `json:"pref_show_snoovatar"`
	Name                    string        `json:"name"`
	PrefClickgadget         uint          `json:"pref_clickgadget"`
	Created                 float64       `json:"created"`
	CreatedUTC              float64       `json:"created_utc"`
	GoldCreddits            uint          `json:"gold_creddits"`
	HasIosSubscription      bool          `json:"has_ios_subscription"`
	PrefShowTwitter         bool          `json:"pref_show_twitter"`
	InBeta                  bool          `json:"in_beta"`
	CommentKarma            uint          `json:"comment_karma"`
	HasSubscribed           bool          `json:"has_subscribed"`
	SeenSubredditChatFtux   bool          `json:"seen_subreddit_chat_ftux"`
}

Me holds information about the currenty logged in user

func (Me) CreatedAt

func (me Me) CreatedAt() time.Time

CreatedAt returns your account creation date

func (Me) GetID

func (me Me) GetID() RedditID

GetID returns the RedditID of You

func (Me) GetURL

func (me Me) GetURL() string

GetURL returns a link to your profile

type MeFeatures

type MeFeatures struct {
	RichtextPreviews                          bool         `json:"richtext_previews"`
	DoNotTrack                                bool         `json:"do_not_track"`
	ChatSubreddit                             bool         `json:"chat_subreddit"`
	Chat                                      bool         `json:"chat"`
	SeqRandomizeSort                          bool         `json:"seq_randomize_sort"`
	Sequence                                  bool         `json:"sequence"`
	MwebXpromoRevampV2                        MeSubFeature `json:"mweb_xpromo_revamp_v2"`
	MwebXpromoFloat64erstitialCommentsIos     bool         `json:"mweb_xpromo_float64erstitial_comments_ios"`
	ChatReddarReports                         bool         `json:"chat_reddar_reports"`
	ChatRollout                               bool         `json:"chat_rollout"`
	MwebXpromoFloat64erstitialCommentsAndroid bool         `json:"mwev_xpromo_float64erstitial_comments_android"`
	ChatGroutRollout                          bool         `json:"chat_group_rollout"`
	MwebLinkTab                               MeSubFeature `json:"mweb_link_tab"`
	SpezModal                                 bool         `json:"spez_modal"`
	CommunityAwards                           bool         `json:"community_awards"`
	DefaultSrsHoldout                         MeSubFeature `json:"default_srs_holdout"`
	ChatUserSettings                          bool         `json:"chat_user_settings"`
	DualWriteUserPrefs                        bool         `json:"dual_write_user_prefs"`

	MwebXpromoModalListingClickDailyDismissibleAndroid bool `json:"mweb_xpromo_modal_listing_click_daily_dismissible_ios"`
	MwebXpromoModalListingClickDailyDismisssibleIos    bool `json:"mweb_xpromo_modal_listing_click_daily_dismissible_android"`
}

MeFeatures are reddit features you can have enabled

type MeSubFeature

type MeSubFeature struct {
	Owner        string  `json:"owner"`
	Variant      string  `json:"variant"`
	ExperimentID float64 `json:"experiment_id"`
}

MeSubFeature is a strange experiments contucted on you!

type ModAction

type ModAction struct {
	Description           string   `json:"description"`
	TargetBody            string   `json:"target_body"`
	ModID36               string   `json:"mod_id36"`
	CreatedUTC            float64  `json:"created_utc"`
	Subreddit             string   `json:"subreddit"`
	TargetTitle           string   `json:"target_title"`
	TargetPermalink       string   `json:"target_permalink"`
	SubredditNamePrefixed string   `json:"subreddit_name_prefixed"`
	Details               string   `json:"details"`
	Action                string   `json:"action"`
	TargetAuthor          string   `json:"target_author"`
	TargetFullname        RedditID `json:"target_fullname"`
	SrID36                string   `json:"sr_id36"`
	ID                    string   `json:"id"`
	Mod                   string   `json:"mod"`
}

ModAction has details about stuff a moderator did. Usually bad stuff.

func (ModAction) CreatedAt

func (m ModAction) CreatedAt() time.Time

CreatedAt returns your account creation date

func (ModAction) GetID

func (m ModAction) GetID() RedditID

GetID returns the RedditID of the ModAction - which isn't actually a RedditID :(

func (ModAction) GetURL

func (m ModAction) GetURL() string

GetURL returns a link to your profile

type ModReport

type ModReport struct {
	Reason string
	Mod    string
}

ModReport is a submission report from a mod. Unlike UserReport, this includes the name of the mod

func (*ModReport) UnmarshalJSON

func (mr *ModReport) UnmarshalJSON(data []byte) error

UnmarshalJSON helps to get ModReport directly from JSON

type NewModmailConversation added in v0.1.1

type NewModmailConversation struct {
	Conversation struct {
		IsAuto bool `json:"isAuto"`
		ObjIds []struct {
			ID  string `json:"id"`
			Key string `json:"key"`
		} `json:"objIds"`
		IsRepliable    bool       `json:"isRepliable"`
		LastUserUpdate *time.Time `json:"lastUserUpdate"`
		IsInternal     bool       `json:"isInternal"`
		LastModUpdate  *time.Time `json:"lastModUpdate"`
		LastUpdated    *time.Time `json:"lastUpdated"`
		Authors        []struct {
			IsMod         bool     `json:"isMod"`
			IsAdmin       bool     `json:"isAdmin"`
			Name          string   `json:"name"`
			IsOp          bool     `json:"isOp"`
			IsParticipant bool     `json:"isParticipant"`
			IsHidden      bool     `json:"isHidden"`
			ID            RedditID `json:"id"`
			IsDeleted     bool     `json:"isDeleted"`
		} `json:"authors"`
		Owner struct {
			DisplayName string   `json:"displayName"`
			Type        string   `json:"type"`
			ID          RedditID `json:"id"`
		} `json:"owner"`
		ID            string          `json:"id"`
		IsHighlighted bool            `json:"isHighlighted"`
		Subject       string          `json:"subject"`
		Participant   json.RawMessage `json:"participant"`
		State         int             `json:"state"`
		LastUnread    *time.Time      `json:"lastUnread"`
		NumMessages   int             `json:"numMessages"`
	} `json:"conversation"`
	Messages map[string]struct {
		Body   string `json:"body"`
		Author struct {
			IsMod         bool     `json:"isMod"`
			IsAdmin       bool     `json:"isAdmin"`
			Name          string   `json:"name"`
			IsOp          bool     `json:"isOp"`
			IsParticipant bool     `json:"isParticipant"`
			IsHidden      bool     `json:"isHidden"`
			ID            RedditID `json:"id"`
			IsDeleted     bool     `json:"isDeleted"`
		} `json:"author"`
		IsInternal   bool      `json:"isInternal"`
		Date         time.Time `json:"date"`
		BodyMarkdown string    `json:"bodyMarkdown"`
		ID           string    `json:"id"`
	} `json:"messages"`
	User struct {
		RecentComments map[RedditID]struct {
			Comment   string    `json:"comment"`
			Date      time.Time `json:"date"`
			Permalink string    `json:"permalink"`
			Title     string    `json:"title"`
		} `json:"recentComments"`
		MuteStatus struct {
			IsMuted bool       `json:"isMuted"`
			EndDate *time.Time `json:"endDate"`
			Reason  string     `json:"reason"`
		} `json:"muteStatus"`
		Name      string    `json:"name"`
		Created   time.Time `json:"created"`
		BanStatus struct {
			EndDate     *time.Time `json:"endDate"`
			Reason      string     `json:"reason"`
			IsBanned    bool       `json:"isBanned"`
			IsPermanent bool       `json:"isPermanent"`
		} `json:"banStatus"`
		IsSuspended    bool `json:"isSuspended"`
		IsShadowBanned bool `json:"isShadowBanned"`
		RecentPosts    map[RedditID]struct {
			Date      time.Time `json:"date"`
			Permalink string    `json:"permalink"`
			Title     string    `json:"title"`
		} `json:"recentPosts"`
		RecentConvos map[string]struct {
			Date      time.Time `json:"date"`
			Permalink string    `json:"permalink"`
			ID        string    `json:"id"`
			Subject   string    `json:"subject"`
		} `json:"recentConvos"`
		ID RedditID `json:"id"`
	} `json:"user"`
	ModActions map[string]struct {
		Date         time.Time `json:"date"`
		ActionTypeID int       `json:"actionTypeId"`
		ID           string    `json:"id"`
		Author       struct {
			Name      string   `json:"name"`
			IsMod     bool     `json:"isMod"`
			IsAdmin   bool     `json:"isAdmin"`
			IsHidden  bool     `json:"isHidden"`
			ID        RedditID `json:"id"`
			IsDeleted bool     `json:"isDeleted"`
		} `json:"author"`
	} `json:"modActions"`
}

NewModmailConversation represents a conversation between a user & mods in the new modmail interface.

type Post

type Post struct {
	ApprovedAtUTC              int64               `json:"approved_at_utc"`
	Subreddit                  string              `json:"subreddit"`
	Selftext                   string              `json:"selftext"`
	AuthorFullname             RedditID            `json:"author_fullname"`
	Saved                      bool                `json:"saved"`
	ModReasonTitle             string              `json:"mod_reason_title"`
	Gilded                     uint                `json:"gilded"`
	Clicked                    bool                `json:"clicked"`
	Title                      string              `json:"title"`
	LinkFlairRichtext          []map[string]string `json:"link_flair_richtext"`
	SubredditNamePrefixed      string              `json:"subreddit_name_prefixed"`
	Hidden                     bool                `json:"hidden"`
	LinkFlairCSSClass          string              `json:"link_flair_css_class"`
	Downs                      int                 `json:"downs"`
	ThumbnailHeight            uint                `json:"thumbnail_height"`
	HideScore                  bool                `json:"hide_score"`
	Name                       RedditID            `json:"name"`
	Quarantine                 bool                `json:"quarantine"`
	LinkFlairTextColor         string              `json:"link_flair_text_color"`
	AuthorFlairBackgroundColor string              `json:"author_flair_background_color"`
	SubredditType              string              `json:"subreddit_type"`
	Ups                        int                 `json:"ups"`
	TotalAwardsReceived        uint                `json:"total_awards_received"`
	MediaEmbed                 json.RawMessage     `json:"media_embed"` // is: []string
	ThumbnailWidth             uint                `json:"thumbnail_width"`
	AuthorFlairTemplateID      string              `json:"author_flair_template_id"`
	IsOriginalContent          bool                `json:"is_original_content"`
	UserReports                []UserReport        `json:"user_reports"`
	SecureMedia                json.RawMessage     `json:"secure_media"`
	// "secure_media": {"reddit_video": {"fallback_url": "https://v.redd.it/cxtki09yq1451/DASH_480?source=fallback", "height": 480, "width": 480, "scrubber_media_url": "https://v.redd.it/cxtki09yq1451/DASH_96", "dash_url": "https://v.redd.it/cxtki09yq1451/DASHPlaylist.mpd?a=1594672415%2CZjE0YThjNzI1NDNlMzkyYzRkZDAyYzZhY2E3NGE1ZTgwZTM0MjVhOWVkYzMxNDhkNzZiNzcwYzIxNmU0MDJjYg%3D%3D&v=1&f=sd", "duration": 6, "hls_url": "https://v.redd.it/cxtki09yq1451/HLSPlaylist.m3u8?a=1594672415%2CM2Q3YWI5MWRjZjE5ZDBkMTgxYTdkNjZhOTEyMjM4ODg1NjFiZDM4OGUwNjEwZTRkMjRmMzhhODlmNzYyODU5Ng%3D%3D&v=1&f=sd", "is_gif": false, "transcoding_status": "completed"}}
	IsRedditMediaDomain bool                `json:"is_reddit_media_domain"`
	IsMeta              bool                `json:"is_meta"`
	Category            string              `json:"category"`
	SecureMediaEmbed    json.RawMessage     `json:"secure_media_embed"` // is: []string
	LinkFlairText       string              `json:"link_flair_text"`
	CanModPost          bool                `json:"can_mod_post"`
	Score               int                 `json:"score"`
	ApprovedBy          string              `json:"approved_by"`
	Thumbnail           string              `json:"thumbnail"`
	Edited              json.RawMessage     `json:"edited"` // bool or float64
	AuthorFlairCSSClass string              `json:"author_flair_css_class"`
	AuthorFlairRichtext []map[string]string `json:"author_flair_richtext"`
	Gildings            map[string]int      `json:"gildings"`
	PostHint            string              `json:"post_hint"`
	ContentCategories   []string            `json:"content_categories"`
	IsSelf              bool                `json:"is_self"`
	ModNote             string              `json:"mod_note"`
	Created             float64             `json:"created"`
	LinkFlairType       string              `json:"link_flair_type"`
	BannedBy            json.RawMessage     `json:"banned_by"`
	AuthorFlairType     string              `json:"author_flair_type"`
	Domain              string              `json:"domain"`
	SelftextHTML        string              `json:"selftext_html"`
	Likes               bool                `json:"likes"`
	SuggestedSort       string              `json:"suggested_sort"`
	BannedAtUTC         float64             `json:"banned_at_utc"`
	ViewCount           uint                `json:"view_count"`
	Archived            bool                `json:"archived"`
	NoFollow            bool                `json:"no_follow"`
	IsCrosspostable     bool                `json:"is_crosspostable"`
	Pinned              bool                `json:"pinned"`
	Over18              bool                `json:"over_18"`
	Preview             struct {
		Images []struct {
			Source      Image   `json:"source"`
			Resolutions []Image `json:"resolutions"`
			ID          string  `json:"id"`
		} `json:"images"`
		Enabled bool `json:"enabled"`
	} `json:"preview"`
	Awardings                []PostAward     `json:"all_awardings"`
	MediaOnly                bool            `json:"media_only"`
	CanGild                  bool            `json:"can_gild"`
	Spoiler                  bool            `json:"spoiler"`
	Locked                   bool            `json:"locked"`
	AuthorFlairText          string          `json:"author_flair_text"`
	Visited                  bool            `json:"visited"`
	NumReports               int             `json:"num_reports"`
	Distinguished            string          `json:"distinguished"`
	SubredditID              RedditID        `json:"subreddit_id"`
	ModReasonBy              string          `json:"mod_reason_by"`
	RemovalReason            string          `json:"removal_reason"`
	LinkFlairBackgroundColor string          `json:"link_flair_background_color"`
	ID                       string          `json:"id"`
	IsRobotIndexable         bool            `json:"is_robot_indexable"`
	Author                   string          `json:"author"`
	NumCrossposts            uint            `json:"num_crossposts"`
	NumComments              uint            `json:"num_comments"`
	SendReplies              bool            `json:"send_replies"`
	WhitelistStatus          string          `json:"whitelist_status"`
	ContestMode              bool            `json:"contest_mode"`
	ModReports               []ModReport     `json:"mod_reports"`
	AuthorPatreonFlair       bool            `json:"author_patreon_flair"`
	AuthorFlairTextColor     string          `json:"author_flair_text_color"`
	Permalink                string          `json:"permalink"`
	ParentWhitelistStatus    string          `json:"parent_whitelist_status"`
	Stickied                 bool            `json:"stickied"`
	URL                      string          `json:"url"`
	SubredditSubscribers     uint            `json:"subreddit_subscribers"`
	CreatedUTC               float64         `json:"created_utc"`
	Media                    json.RawMessage `json:"media"`
	// "media": {"reddit_video": {"fallback_url": "https://v.redd.it/cxtki09yq1451/DASH_480?source=fallback", "height": 480, "width": 480, "scrubber_media_url": "https://v.redd.it/cxtki09yq1451/DASH_96", "dash_url": "https://v.redd.it/cxtki09yq1451/DASHPlaylist.mpd?a=1594672415%2CZjE0YThjNzI1NDNlMzkyYzRkZDAyYzZhY2E3NGE1ZTgwZTM0MjVhOWVkYzMxNDhkNzZiNzcwYzIxNmU0MDJjYg%3D%3D&v=1&f=sd", "duration": 6, "hls_url": "https://v.redd.it/cxtki09yq1451/HLSPlaylist.m3u8?a=1594672415%2CM2Q3YWI5MWRjZjE5ZDBkMTgxYTdkNjZhOTEyMjM4ODg1NjFiZDM4OGUwNjEwZTRkMjRmMzhhODlmNzYyODU5Ng%3D%3D&v=1&f=sd", "is_gif": false, "transcoding_status": "completed"}}
	IsVideo  bool `json:"is_video"`
	Approved bool `json:"approved"`
	Removed  bool `json:"removed"`
}

Post defines a reddit post (t3_XXXXX)

func (Post) CreatedAt

func (p Post) CreatedAt() time.Time

CreatedAt returns time.Time the Post was created at

func (Post) GetApproved

func (p Post) GetApproved() SubModAction

GetApproved returns the mod & time who approved the Post

func (Post) GetAuthor

func (p Post) GetAuthor() string

GetAuthor returns the name of the Post Author

func (Post) GetAuthorID

func (p Post) GetAuthorID() RedditID

GetAuthorID returns the RedditID of the Post Author

func (Post) GetBanned

func (p Post) GetBanned() SubModAction

GetBanned returns the mod & time who deleted the Post

func (Post) GetBody

func (p Post) GetBody() string

GetBody returns the content of the Post in Markdown

func (Post) GetCreated added in v0.1.7

func (p Post) GetCreated() time.Time

GetCreated returns the creation date of the Post

func (Post) GetID

func (p Post) GetID() RedditID

GetID returns the RedditID of the Post

func (Post) GetParentID

func (p Post) GetParentID() RedditID

GetParentID returns the parent RedditID of the Post

func (Post) GetReports

func (p Post) GetReports() AllReports

GetReports returns the reports for the Post

func (Post) GetScore

func (p Post) GetScore() int

GetScore returns the current score of the Post

func (Post) GetSubreddit

func (p Post) GetSubreddit() string

GetSubreddit returns the name of the Subreddit the post was posted in

func (Post) GetSubredditID

func (p Post) GetSubredditID() RedditID

GetSubredditID returns the RedditID of the subreddit the post was posted in

func (Post) GetTitle

func (p Post) GetTitle() string

GetTitle returns the title of the Post

func (Post) GetURL

func (p Post) GetURL() string

GetURL returns the link to the Post

func (Post) IsApproved

func (p Post) IsApproved() bool

IsApproved tells you if the post has been approved (only if you are mod)

func (Post) IsRemoved

func (p Post) IsRemoved() bool

IsRemoved tells you if the post has been removed (only if you are mod)

func (Post) IsSticky

func (p Post) IsSticky() bool

IsSticky tells you if the Post has been stickied

type PostActionResponse added in v0.1.8

type PostActionResponse struct {
	JSON struct {
		Errors []string `json:"errors"`
		Data   struct {
			Name RedditID `json:"name"`
			URL  string   `json:"url"`
		}
	} `json:"json"`
}

PostActionResponse is returned by reddit when you create a post

type PostAward

type PostAward struct {
	IsEnabled           bool     `json:"is_enabled"`
	Count               uint     `json:"count"`
	SubredditID         RedditID `json:"subreddit_id"`
	Description         string   `json:"description"`
	CoinReward          uint     `json:"coin_reward"`
	IconWidth           uint     `json:"icon_width"`
	IconURL             string   `json:"icon_url"`
	DaysOfPremium       uint     `json:"days_of_premium"`
	IconHeight          float64  `json:"icon_height"`
	ResizedIcons        []Image  `json:"resized_icons"`
	DaysOfDripExtension float64  `json:"days_of_drip_extension"`
	AwardType           string   `json:"award_type"`
	CoinPrice           uint     `json:"coin_price"`
	ID                  string   `json:"id"`
	Name                string   `json:"name"`
}

PostAward defines a post "hipster gilding"

type RedditElement

type RedditElement struct {
	Kind RedditKind  `json:"kind"`
	Data RedditThing `json:"data"`
}

RedditElement contains a Reddit Element. The returned Element is defined by Kind.

func (*RedditElement) UnmarshalJSON

func (r *RedditElement) UnmarshalJSON(data []byte) error

UnmarshalJSON helps to convert RedditElement.Data into a useful object depending on Kind

type RedditID

type RedditID string

RedditID is a Reddit Thing ID (tX_XXXXX)

func (RedditID) Type

func (r RedditID) Type() RedditKind

Type returns the RedditKind to a RedditID

func (*RedditID) UnmarshalJSON added in v0.1.1

func (r *RedditID) UnmarshalJSON(data []byte) error

UnmarshalJSON defines an Unmarshaller for RedditID This is mainly used to convert int values (used in New Modmail responses) to the base36 one used elsewhere.

type RedditKind

type RedditKind string

RedditKind defines the type of of a Reddit ID (tX)

const (
	KComment   RedditKind = "t1"
	KRedditor  RedditKind = "t2"
	KPost      RedditKind = "t3"
	KMessage   RedditKind = "t4"
	KSubreddit RedditKind = "t5"
	KAward     RedditKind = "t6"
	KModAction RedditKind = "modaction"
	KUnknown   RedditKind = "tX"
)

List of all possible RedditKinds

type RedditThing

type RedditThing interface {
	GetID() RedditID
	CreatedAt() time.Time
	GetURL() string
}

RedditThing provides an interface to access common attributes of reddit stuff without having to type hint it.

type Redditor

type Redditor struct {
	IsEmployee        bool          `json:"is_employee"`
	IconImg           string        `json:"icon_img"`
	PrefShowSnoovatar bool          `json:"pref_show_snoovatar"`
	Name              string        `json:"name"`
	IsFriend          bool          `json:"is_friend"`
	Created           float64       `json:"created"`
	HasSubscribed     bool          `json:"has_subscribed"`
	HideFromRobots    bool          `json:"hide_from_robots"`
	CreatedUTC        float64       `json:"created_utc"`
	LinkKarma         int           `json:"link_karma"`
	CommentKarma      int           `json:"comment_karma"`
	IsGold            bool          `json:"is_gold"`
	IsMod             bool          `json:"is_mod"`
	Verified          bool          `json:"verified"`
	Subreddit         userSubreddit `json:"subreddit"`
	HasVerifiedEmail  bool          `json:"has_verified_email"`
	ID                string        `json:"id"`
}

Redditor represents another user

func (Redditor) CreatedAt

func (r Redditor) CreatedAt() time.Time

CreatedAt returns your account creation date

func (Redditor) GetID

func (r Redditor) GetID() RedditID

GetID returns the RedditID of You

func (Redditor) GetURL

func (r Redditor) GetURL() string

GetURL returns a link to your profile

type Response

type Response struct {
	Kind responseType
	Data interface{}
}

Response is a reply from the reddit API. It can be of different Kinds (Respond Types), and contains different Data (depending on Kind)

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON helps to convert Response.Data into a useful object depending on Kind

type Stylesheet added in v0.1.10

type Stylesheet struct {
	Images []struct {
		URL  string `json:"url"`
		Link string `json:"link"`
		Name string `json:"name"`
	} `json:"images"`
	SubredditID RedditID `json:"subreddit_id"`
	Stylesheet  string   `json:"stylesheet"`
}

Stylesheet has details abouta a subreddits stylesheet.

type SubModAction

type SubModAction struct {
	Mod string
	At  time.Time
}

SubModAction is a removal/approval with a timestamp

type Submission

type Submission interface {
	RedditThing
	GetAuthor() string
	GetAuthorID() RedditID
	GetSubreddit() string
	GetSubredditID() RedditID
	GetParentID() RedditID
	GetTitle() string
	GetBody() string
	GetScore() int
	IsSticky() bool
	GetCreated() time.Time
	// Mod Stuff
	IsRemoved() bool
	IsApproved() bool
	GetBanned() SubModAction
	GetApproved() SubModAction
	GetReports() AllReports
}

Submission provides an interface to access common attributes of posts & comments without having to type hint it.

type Subreddit

type Subreddit struct {
	UserFlairBackgroundColor   string   `json:"user_flair_background_color"`
	SubmitTextHTML             string   `json:"submit_text_html"`
	RestrictPosting            bool     `json:"restrict_posting"`
	UserIsBanned               bool     `json:"user_is_banned"`
	FreeFormReports            bool     `json:"free_form_reports"`
	WikiEnabled                bool     `json:"wiki_enabled"`
	UserIsMuted                bool     `json:"user_is_muted"`
	UserCanFlairInSr           string   `json:"user_can_flair_in_sr"`
	DisplayName                string   `json:"display_name"`
	HeaderImg                  string   `json:"header_img"`
	Title                      string   `json:"title"`
	IconSize                   []int    `json:"icon_size"`
	PrimaryColor               string   `json:"primary_color"`
	ActiveUserCount            int      `json:"active_user_count"`
	IconImg                    string   `json:"icon_img"`
	AccountsActive             int      `json:"accounts_active"`
	PublicTraffic              bool     `json:"public_traffic"`
	Subscribers                int      `json:"subscribers"`
	UserFlairRichtext          string   `json:"user_flair_richtext"`
	VideostreamLinksCount      int      `json:"videostream_links_count"`
	Name                       RedditID `json:"name"`
	Quarantine                 bool     `json:"quarantine"`
	HideAds                    bool     `json:"hide_ads"`
	EmojisEnabled              bool     `json:"emojis_enabled"`
	AdvertiserCategory         string   `json:"advertiser_category"`
	PublicDescription          string   `json:"public_description"`
	CommentScoreHideMins       int      `json:"comment_score_hide_mins"`
	UserHasFavorited           bool     `json:"user_has_favorited"`
	UserFlairTemplateID        string   `json:"user_flair_template_id"`
	CommunityIcon              string   `json:"community_icon"`
	BannerBackgroundImage      string   `json:"banner_background_image"`
	OriginalContentTagEnabled  bool     `json:"original_content_tag_enabled"`
	SubmitText                 string   `json:"submit_text"`
	DescriptionHTML            string   `json:"description_html"`
	SpoilersEnabled            bool     `json:"spoilers_enabled"`
	HeaderTitle                string   `json:"header_title"`
	HeaderSize                 string   `json:"header_size"`
	UserFlairPosition          string   `json:"user_flair_position"`
	AllOriginalContent         bool     `json:"all_original_content"`
	HasMenuWidget              bool     `json:"has_menu_widget"`
	IsEnrolledInNewModmail     bool     `json:"is_enrolled_in_new_modmail"`
	KeyColor                   string   `json:"key_color"`
	EventPostsEnabled          bool     `json:"event_posts_enabled"`
	CanAssignUserFlair         bool     `json:"can_assign_user_flair"`
	Created                    float64  `json:"created"`
	ShowMediaPreview           bool     `json:"show_media_preview"`
	SubmissionType             string   `json:"submission_type"`
	UserIsSubscriber           bool     `json:"user_is_subscriber"`
	DisableContributorRequests bool     `json:"disable_contributor_requests"`
	AllowVideoGIFs             bool     `json:"allow_videogifs"`
	UserFlairType              string   `json:"user_flair_type"`
	CollapseDeletedComments    bool     `json:"collapse_deleted_comments"`
	EmojisCustomSize           string   `json:"emojis_custom_size"`
	PublicDescriptionHTML      string   `json:"public_description_html"`
	AllowVideos                bool     `json:"allow_videos"`
	NotificationLevel          string   `json:"notification_level"`
	CanAssignLinkFlair         bool     `json:"can_assign_link_flair"`
	AccountsActiveIsFuzzed     bool     `json:"accounts_active_is_fuzzed"`
	SubmitTextLabel            string   `json:"submit_text_label"`
	LinkFlairPosition          string   `json:"link_flair_position"`
	UserSrFlairEnabled         bool     `json:"user_sr_flair_enabled"`
	UserFlairEnabledInSr       bool     `json:"user_flair_enabled_in_sr"`
	AllowDiscovery             bool     `json:"allow_discovery"`
	UserSrThemeEnabled         bool     `json:"user_sr_theme_enabled"`
	LinkFlairEnabled           bool     `json:"link_flair_enabled"`
	SubredditType              string   `json:"subreddit_type"`
	SuggestedCommentSort       string   `json:"suggested_comment_sort"`
	BannerImg                  string   `json:"banner_img"`
	UserFlairText              string   `json:"user_flair_text"`
	BannerBackgroundColor      string   `json:"banner_background_color"`
	ShowMedia                  bool     `json:"show_media"`
	ID                         string   `json:"id"`
	UserIsModerator            bool     `json:"user_is_moderator"`
	Over18                     bool     `json:"over18"`
	Description                string   `json:"description"`
	SubmitLinkLabel            string   `json:"submit_link_label"`
	UserFlairTextColor         string   `json:"user_flair_text_color"`
	RestrictCommenting         bool     `json:"restrict_commenting"`
	UserFlairCSSClass          string   `json:"user_flair_css_class"`
	AllowImages                bool     `json:"allow_images"`
	Lang                       string   `json:"lang"`
	WhitelistStatus            string   `json:"whitelist_status"`
	URL                        string   `json:"url"`
	CreatedUTC                 float64  `json:"created_utc"`
	BannerSize                 []int64  `json:"banner_size"`
	MobileBannerImage          string   `json:"mobile_banner_image"`
	UserIsContributor          bool     `json:"user_is_contributor"`
}

Subreddit represents a subreddit

func (Subreddit) CreatedAt

func (s Subreddit) CreatedAt() time.Time

CreatedAt returns the time.Time of the Subreddits creation

func (Subreddit) GetID

func (s Subreddit) GetID() RedditID

GetID returns the Subreddit RedditID

func (Subreddit) GetURL

func (s Subreddit) GetURL() string

GetURL returns the Subreddit URL

type UserReport

type UserReport struct {
	Reason string
	Count  int
}

UserReport is a submission report from a user

func (*UserReport) UnmarshalJSON

func (ur *UserReport) UnmarshalJSON(data []byte) error

UnmarshalJSON helps to get UserReport directly from JSON

type Wiki

type Wiki struct {
	ContentMD    string        `json:"content_md"`
	MayRevise    bool          `json:"may_revise"`
	Reason       string        `json:"reason"`
	RevisionDate int           `json:"revision_date"`
	RevisionBy   RedditElement `json:"revision_by"`
	RevisionID   string        `json:"revision_id"`
	ContentHTML  string        `json:"content_html"`
}

Wiki defines a Wiki Page

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL