reddit

package
v0.0.0-...-f862058 Latest Latest
Warning

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

Go to latest
Published: May 23, 2018 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeAccount          AuthScope = "account"          // Update preferences and related account information. Will not have access to your email or password.
	ScopeCreddits                   = "creddits"         // Spend my reddit gold creddits on giving gold to other users.
	ScopeEdit                       = "edit"             // Edit and delete my comments and submissions.
	ScopeFlair                      = "flair"            // Select my subreddit flair. Change link flair on my submissions.
	ScopeHistory                    = "history"          // Access my voting history and comments or submissions I've saved or hidden.
	ScopeIdentity                   = "identity"         // Access my reddit username and signup date.
	ScopeLivemanage                 = "livemanage"       // Manage settings and contributors of live threads I contribute to.
	ScopeModconfig                  = "modconfig"        // Manage the configuration, sidebar, and CSS of subreddits I moderate.
	ScopeModcontributors            = "modcontributors"  // Add/remove users to approved submitter lists and ban/unban or mute/unmute users from subreddits I moderate.
	ScopeModflair                   = "modflair"         // Manage and assign flair in subreddits I moderate.
	ScopeModlog                     = "modlog"           // Access the moderation log in subreddits I moderate.
	ScopeModmail                    = "modmail"          // Access and manage modmail via mod.reddit.com.
	ScopeModothers                  = "modothers"        // Invite or remove other moderators from subreddits I moderate.
	ScopeModposts                   = "modposts"         // Approve, remove, mark nsfw, and distinguish content in subreddits I moderate.
	ScopeModself                    = "modself"          // Accept invitations to moderate a subreddit. Remove myself as a moderator or contributor of subreddits I moderate or contribute to.
	ScopeModtraffic                 = "modtraffic"       // Access traffic stats in subreddits I moderate.
	ScopeModwiki                    = "modwiki"          // Change editors and visibility of wiki pages in subreddits I moderate.
	ScopeMysubreddits               = "mysubreddits"     // Access the list of subreddits I moderate, contribute to, and subscribe to.
	ScopePrivatemessages            = "privatemessages"  // Access my inbox and send private messages to other users.
	ScopeRead                       = "read"             // Access posts and comments through my account.
	ScopeReport                     = "report"           // Report content for rules violations. Hide & show individual submissions.
	ScopeSave                       = "save"             // Save and unsave comments and submissions.
	ScopeStructuredstyles           = "structuredstyles" // Edit structured styles for a subreddit I moderate.
	ScopeSubmit                     = "submit"           // Submit links and comments from my account.
	ScopeSubscribe                  = "subscribe"        // Manage my subreddit subscriptions. Manage \"friends\" - users whose content I follow.
	ScopeVote                       = "vote"             // Submit and change my votes on comments and submissions.
	ScopeWikiedit                   = "wikiedit"         // Edit wiki pages on my behalf.
	ScopeWikiread                   = "wikiread"         // Read wiki pages through my account.
)
View Source
const (
	SortDefault       ListingSort = ""
	SortHot                       = "hot"
	SortNew                       = "new"
	SortRising                    = "rising"
	SortTop                       = "top"
	SortControversial             = "controversial"
)
View Source
const (
	TimeDefault ListingTime = ""
	TimeHour                = "hour"
	TimeDay                 = "day"
	TimeWeek                = "week"
	TimeMonth               = "month"
	TimeYear                = "year"
	TimeAllTime             = "all"
)
View Source
const (
	GLOBAL ListingLocation = "GLOBAL"
	US                     = "US"
	AR                     = "AR"
	AU                     = "AU"
	BG                     = "BG"
	CA                     = "CA"
	CL                     = "CL"
	CO                     = "CO"
	HR                     = "HR"
	CZ                     = "CZ"
	FI                     = "FI"
	GR                     = "GR"
	HU                     = "HU"
	IS                     = "IS"
	IN                     = "IN"
	IE                     = "IE"
	JP                     = "JP"
	MY                     = "MY"
	MX                     = "MX"
	NZ                     = "NZ"
	PH                     = "PH"
	PL                     = "PL"
	PT                     = "PT"
	PR                     = "PR"
	RO                     = "RO"
	RS                     = "RS"
	SG                     = "SG"
	SE                     = "SE"
	TW                     = "TW"
	TH                     = "TH"
	TR                     = "TR"
	GB                     = "GB"
	USWA                   = "US_WA"
	USDE                   = "US_DE"
	USDC                   = "US_DC"
	USWI                   = "US_WI"
	USWV                   = "US_WV"
	USHI                   = "US_HI"
	USFL                   = "US_FL"
	USWY                   = "US_WY"
	USNH                   = "US_NH"
	USNJ                   = "US_NJ"
	USNM                   = "US_NM"
	USTX                   = "US_TX"
	USLA                   = "US_LA"
	USNC                   = "US_NC"
	USND                   = "US_ND"
	USNE                   = "US_NE"
	USTN                   = "US_TN"
	USNY                   = "US_NY"
	USPA                   = "US_PA"
	USCA                   = "US_CA"
	USNV                   = "US_NV"
	USVA                   = "US_VA"
	USCO                   = "US_CO"
	USAK                   = "US_AK"
	USAL                   = "US_AL"
	USAR                   = "US_AR"
	USVT                   = "US_VT"
	USIL                   = "US_IL"
	USGA                   = "US_GA"
	USIN                   = "US_IN"
	USIA                   = "US_IA"
	USOK                   = "US_OK"
	USAZ                   = "US_AZ"
	USID                   = "US_ID"
	USCT                   = "US_CT"
	USME                   = "US_ME"
	USMD                   = "US_MD"
	USMA                   = "US_MA"
	USOH                   = "US_OH"
	USUT                   = "US_UT"
	USMO                   = "US_MO"
	USMN                   = "US_MN"
	USMI                   = "US_MI"
	USRI                   = "US_RI"
	USKS                   = "US_KS"
	USMT                   = "US_MT"
	USMS                   = "US_MS"
	USSC                   = "US_SC"
	USKY                   = "US_KY"
	USOR                   = "US_OR"
	USSD                   = "US_SD"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthScope

type AuthScope string

type ListingLocation

type ListingLocation string

type ListingOptions

type ListingOptions struct {
	After    string
	Before   string
	Count    int
	Limit    int
	Show     bool
	Detail   bool
	Location ListingLocation // Hot only
	Time     ListingTime     // Top & Controversial only
	Sort     ListingSort
	Reddit   string
}

func (ListingOptions) Validate

func (l ListingOptions) Validate() error

type ListingPost

type ListingPost struct {
	Kind string          `json:"kind"`
	Data ListingPostData `json:"data"`
}

type ListingPostData

type ListingPostData struct {
	ApprovedAtUtc     interface{}   `json:"approved_at_utc"`
	Subreddit         string        `json:"subreddit"`
	Selftext          string        `json:"selftext"`
	UserReports       []interface{} `json:"user_reports"`
	IsSaved           bool          `json:"saved"`
	ModReasonTitle    interface{}   `json:"mod_reason_title"`
	Gilded            int           `json:"gilded"`
	IsClicked         bool          `json:"clicked"`
	Title             string        `json:"title"`
	LinkFlairRichtext []struct {
		E string `json:"e"`
		T string `json:"t"`
	} `json:"link_flair_richtext"`
	SubredditNamePrefixed      string      `json:"subreddit_name_prefixed"`
	IsHidden                   bool        `json:"hidden"`
	Pwls                       int         `json:"pwls"`
	LinkFlairCSSClass          string      `json:"link_flair_css_class"`
	Downs                      int         `json:"downs"`
	ThumbnailHeight            int         `json:"thumbnail_height"`
	ParentWhitelistStatus      string      `json:"parent_whitelist_status"`
	HideScore                  bool        `json:"hide_score"`
	Name                       string      `json:"name"`
	Quarantine                 bool        `json:"quarantine"`
	LinkFlairTextColor         string      `json:"link_flair_text_color"`
	AuthorFlairBackgroundColor interface{} `json:"author_flair_background_color"`
	SubredditType              string      `json:"subreddit_type"`
	Ups                        int         `json:"ups"`
	Domain                     string      `json:"domain"`
	MediaEmbed                 struct {
	} `json:"media_embed"`
	ThumbnailWidth        int         `json:"thumbnail_width"`
	AuthorFlairTemplateID interface{} `json:"author_flair_template_id"`
	IsOriginalContent     bool        `json:"is_original_content"`
	SecureMedia           interface{} `json:"secure_media"`
	IsRedditMediaDomain   bool        `json:"is_reddit_media_domain"`
	Category              interface{} `json:"category"`
	SecureMediaEmbed      struct {
	} `json:"secure_media_embed"`
	LinkFlairText string      `json:"link_flair_text"`
	CanModPost    bool        `json:"can_mod_post"`
	Score         int         `json:"score"`
	ApprovedBy    interface{} `json:"approved_by"`
	Thumbnail     string      `json:"thumbnail"`
	//Edited              bool          `json:"edited"` // Timestamp or false
	AuthorFlairCSSClass string        `json:"author_flair_css_class"`
	AuthorFlairRichtext []interface{} `json:"author_flair_richtext"`
	PostHint            string        `json:"post_hint"`
	IsSelf              bool          `json:"is_self"`
	ModNote             interface{}   `json:"mod_note"`
	Created             float64       `json:"created"`
	LinkFlairType       string        `json:"link_flair_type"`
	Wls                 int           `json:"wls"`
	PostCategories      interface{}   `json:"post_categories"`
	BannedBy            interface{}   `json:"banned_by"`
	AuthorFlairType     string        `json:"author_flair_type"`
	ContestMode         bool          `json:"contest_mode"`
	SelftextHTML        interface{}   `json:"selftext_html"`
	Likes               interface{}   `json:"likes"`
	SuggestedSort       interface{}   `json:"suggested_sort"`
	BannedAtUtc         interface{}   `json:"banned_at_utc"`
	ViewCount           interface{}   `json:"view_count"`
	Archived            bool          `json:"archived"`
	NoFollow            bool          `json:"no_follow"`
	IsCrosspostable     bool          `json:"is_crosspostable"`
	Pinned              bool          `json:"pinned"`
	IsOver18            bool          `json:"over_18"`
	Preview             struct {
		Images []struct {
			Source struct {
				URL    string `json:"url"`
				Width  int    `json:"width"`
				Height int    `json:"height"`
			} `json:"source"`
			Resolutions []struct {
				URL    string `json:"url"`
				Width  int    `json:"width"`
				Height int    `json:"height"`
			} `json:"resolutions"`
			Variants struct {
			} `json:"variants"`
			ID string `json:"id"`
		} `json:"images"`
		Enabled bool `json:"enabled"`
	} `json:"preview"`
	CanGild              bool          `json:"can_gild"`
	IsSpoiler            bool          `json:"spoiler"`
	Locked               bool          `json:"locked"`
	AuthorFlairText      string        `json:"author_flair_text"`
	RteMode              string        `json:"rte_mode"`
	IsVisited            bool          `json:"visited"`
	NumReports           interface{}   `json:"num_reports"`
	Distinguished        interface{}   `json:"distinguished"`
	SubredditID          string        `json:"subreddit_id"`
	ModReasonBy          interface{}   `json:"mod_reason_by"`
	RemovalReason        interface{}   `json:"removal_reason"`
	ID                   string        `json:"id"`
	ReportReasons        interface{}   `json:"report_reasons"`
	Author               string        `json:"author"`
	NumCrossposts        int           `json:"num_crossposts"`
	NumComments          int           `json:"num_comments"`
	SendReplies          bool          `json:"send_replies"`
	ModReports           []interface{} `json:"mod_reports"`
	AuthorFlairTextColor interface{}   `json:"author_flair_text_color"`
	Permalink            string        `json:"permalink"`
	WhitelistStatus      string        `json:"whitelist_status"`
	Stickied             bool          `json:"stickied"`
	URL                  string        `json:"url"`
	SubredditSubscribers int           `json:"subreddit_subscribers"`
	CreatedUtc           float64       `json:"created_utc"`
	Media                interface{}   `json:"media"`
	IsVideo              bool          `json:"is_video"`
}

func (ListingPostData) IsImage

func (d ListingPostData) IsImage() bool

type ListingResponse

type ListingResponse struct {
	Kind string `json:"kind"`
	Data struct {
		Modhash  string        `json:"modhash"`
		Dist     int           `json:"dist"`
		Children []ListingPost `json:"children"`
		After    string        `json:"after"`
		Before   interface{}   `json:"before"`
	} `json:"data"`
}

type ListingSort

type ListingSort string

type ListingTime

type ListingTime string

type Reddit

type Reddit struct {
	// contains filtered or unexported fields
}

func GetClient

func GetClient(client string, secret string, redirect string, userAgent string) (reddit Reddit)

func (Reddit) GetListing

func (r Reddit) GetListing(options ListingOptions) (posts *ListingResponse, err error)

func (Reddit) GetToken

func (r Reddit) GetToken(re *http.Request) (tok *oauth2.Token, err error)

func (Reddit) Login

func (r Reddit) Login(scopes []AuthScope, mobile bool, state string) (string, string)

func (Reddit) Save

func (r Reddit) Save(id string, category string) (err error)

func (*Reddit) SetToken

func (r *Reddit) SetToken(tok *oauth2.Token)

func (*Reddit) Throttle

func (r *Reddit) Throttle(duration time.Duration)

func (Reddit) Unsave

func (r Reddit) Unsave(id string) (err error)

Jump to

Keyboard shortcuts

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